ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 1 of 10 ITECH1400 - Assignment 2 – FedUni Banking Due Date: 5pm, Friday...

1 answer below »
complete my assignment


ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 1 of 10 ITECH1400 - Assignment 2 – FedUni Banking Due Date: 5pm, Friday of Week 11 This assignment will test your skills in designing and programming applications to specification and is worth 20% of your non-invigilated (type A) marks for this course. This is an INDIVIDUAL ASSIGNMENT – and while you may discuss it with your fellow students, you must not share designs or code or you will be in breach of the university plagiarism rules. This assignment should take you approximately 20 hours to complete. Assignment Overview You are tasked with creating an application that uses a GUI that simulates a simple banking interface similar to an ATM / online banking using the Python 3 programming language. The assignment is broken up into five main components: 1.) The ability to provide an account id and a PIN (Personal Identification Number) to sign into a bank account, 2.) The ability to view the balance of the bank account and to deposit and withdraw virtual money into and out from the account, 3.) The ability to save transactions via file storage so that you can log in, deposit some money and then log out – and when you log back in that money is still there, and finally 4.) The ability to display a graph of projected earnings on the bank account via the compound interest accrued over a variable amount of time. 5.) A Test Case that ensures your BankAccount's deposit and withdraw functionality operates correctly. Your submission should consist of three Python scripts that implement this application as described in the following pages: bankaccount.py, main.py along with a testbankaccount.py which contains a small test case with a few simple unit tests than ensure that your bank accounts deposit and withdraw methods operate correctly. You are provided with a 'stub' of each of these files which contain all the function declarations and comments which describe the role of the function and how it can be put together, but you will have to write the code for vast majority of the functions yourself. You are also provided with a stub of the bankaccounttestcase.py file. Your final submission should be a zipped archive (i.e. ‘zip file’) containing your completed Python scripts. There is no word processed component to this second assignment. ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 2 of 10 Bank Account Class Design The design for a BankAccount object is laid out in the following class diagram: As you might imagine, the deposit(amount) function adds that money to the current balance of the account, and the withdraw(amount) function removes (i.e. subtracts) money from the current balance of the account. Each transaction in the transaction_list is a tuple containing either the word Deposit or the word Withdrawal followed by an amount, for example: ("Deposit", 300.0) or ("Withdrawal", 100.0). The bank accounts in our program do not have an overdraft facility so the user cannot withdraw money they do not have – that is, if they had $200 in their account and they tried to withdraw more than $200 then the operation should fail and the withdraw function should raise an Exception with a suitable error message which is caught and displayed in the main.py file where the operation was attempted. All error messages such as those from exceptions should be displayed in a pop-up messagebox. The get_transaction_string method should loop over all the transactions in the transaction_list creating a string version (with newline characters) of all the transactions associated with the account. The export_to_file function should save the account_id, pin_number, balance, and interest_rate in that order to a file called .txt followed by the transaction list string generated from the get_transaction_string() method. The name of the account file is NOT '.txt' - the name of the file is the ACTUAL ACCOUNT ID followed by ".txt", so for an account with account_id 123456 the name of the account file would be 123456.txt. A full ‘walk-through’ video demonstrating the completed application and how it operates will be provided along with this assignment document. BankAccount account_id: int pin_number: string balance: float interest_rate: float transaction_list: list of two-tuples deposit(amount) withdraw(amount) get_transaction_string() export_to_file() ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 3 of 10 Calculating Interest To make it worthwhile for you to keep your money with a bank, the bank offers you an interest rate on your savings. Interest will be applied to the balance of an account once per month. Let’s do an example – suppose you had $10,000 in a bank account and the bank paid you monthly interest at a rate of 3% per year. That would mean the bank pays you 3% of your balance divided by 12 (because there are 12 months in a year) per month. If we start our example on January and run it for a few months (and we don’t deposit or withdraw any money throughout the year) then we end up with our bank balance changing like this: Note: 3% divided by 12 is 0.25% per month – so we’ll multiply our balance by 1.0025 to get the new balance. Jan Feb Mar Apr May Jun Jul Aug Etc. 10,000.00 10,025.00 10,050.06 10,075.19 10,100.38 10,125.63 10,150.94 10,176.32 … What’s happening here is that the interest is compounding – which just means that we get that 0.25% applied not only to our principle balance (i.e. the $10,000 we started with), but it also gets applied to the interest we earnt. Although 3% interest is very low (but in line with the best rates you’d get in Australia at the moment because interest rates are very low), over time this compounding makes a serious difference! Because FedUni Bank is the greatest bank of all time, it offers all accounts an interest rate of 33%. The Main Python Script Our main.py script will contain all the main logic for our program. It will allow us to: - Enter an account id via an Entry field by using the keyboard, - Enter a PIN number via an Entry widget (we can use the keyboard OR a series of buttons to enter the PIN), - Once we are logged in we must be able to: o See the balance of our account, o Deposit funds into our account, o Withdraw funds from our account (only up to the amount we have available), o Display a plot of our projected interest over the next 12 months as outlined above, and finally o Log out of our account. Every time a successful deposit or withdrawal is made then a new transaction should be added to the account's transaction list. When we log out then the account file is overwritten with the new account details including our new balance and any transactions if any have been made. The format of the account text file is as follows (each value on separate lines): account_id account_pin balance interest_rate ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 4 of 10 For example, account id 123456 with PIN 7890 and a balance of $800 with an interest rate of 33% would look like this: 123456 7890 800.00 0.33 After these first four lines we may have a number of transactions, each of which is specified as two lines. A deposit is indicated by the word Deposit on one line and then the amount on the next like. For example a deposit of $500 would look like this: Deposit 500.00 Similarly, a withdrawal is also specified as two lines – first the word Withdrawal and then on the next line the amount, for example a withdrawal of $200 would look like this: Withdrawal 200.00 You are provided with an example bank account file called 12345678.txt – this file along with others will be used to mark your assessment, so you should make sure that your final submission can use bank accounts in this format successfully. You are also provided with a video demonstration of the completed assignment along with this document. Your application should match this user interface and function in the same way. Login Screen When the application is first launched, it should open a window that is "440x640" pixels in size (use the window object’s geometry function to set this). Set the title of the window to "FedUni Banking" using the top-level window object's winfo_toplevel().title() function. The window uses the GridManager layout manager for placing GUI elements (e.g. 'widgets'), it contains a Label that spans the top of the window saying "FedUni Banking" (font size is 32). On the next line is a label saying "Account id" and then an Entry widget for the user to type in their account id and an Entry for the PIN number. It then has a series of buttons from 0 through 9, along with a Log In button and a Clear/Cancel button. Each time a number is pressed it is added to a string - for example, if the user pushed the 4 button then the 3 button then the 2 button and then the 1 button then the string should contain the text "4321". By using the show="*" attribute you can 'mask' the input so that anyone looking over your shoulder cannot see the exact pin number, they'll just see "****" instead. When the Clear/Cancel button is pressed, or when a user "logs out" then this PIN string should be reset to an empty string. When the Log In button is pressed then the program should attempt to open the file with the account id followed by ".txt" - so in the example below, because the account id entered was "123456", the program will attempt to open the file "123456.txt". ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 5 of 10 If that file could not be opened then a messagebox should display
Answered Same DaySep 24, 2020ITECH1400

Answer To: ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology...

Akash answered on Sep 26 2020
164 Votes
assignment1/calc.py
from tkinter import *
from tkinter import ttk
class Calculator:
# Stores the current value to display in the entry
calc_value = 0.0
# Will define if this was the last math button clicked
div_trigger = False
mult_trigger = False
add_trigger = False
sub_trigger = False
# Called anytime a number button is pressed
def button_press(self, value):
# Get the current value in the entry
entry_val = self.number_entry.get()
# Put the new value to the right of it
# If it was 1 and 2 is pressed it is now 12
# Otherwise the new number goes on the left
entry_val += value
# Clear the entry box
self.number_entry.delete(0, "end")
# Insert the new value going from left to right
self.number_entry.insert(0, entry_val)
# Returns True or False if the string is a float
def isfloat(self, str_val):
try:
# If the string isn't a float float() will throw a
# ValueError
float(str_val)
# If there is a value you want to return use return
return True
except ValueError:
return False
# Handles logic when math buttons are pressed
def math_button_press(self, value):
# Only do anything if entry currently contains a number
if self.isfloat(str(self.number_entry.get())):
# make false to cancel out previous math button click
self.add_trigger = False
self.sub_trigger = False
self.mult_trigger = False
self.div_trigger = False
# Get the value out of the entry box for the calculation
self.calc_value = float(self.entry_value.get())
# Set the math button click so when equals is clicked
# that function knows what calculation to use
if value == "/":
print("/ Pressed")
self.div_trigger = True
elif value == "*":
print("* Pressed")
self.mult_trigger = True
elif value == "+":
print("+ Pressed")
self.add_trigger = True
else:
print("- Pressed")
self.sub_trigger = True
# Clear the entry box
self.number_entry.delete(0, "end")
# Performs a mathematical operation by taking the value before
# the math button is clicked and the current value. Then perform
# the right calculation by checking what math button was clicked
# last
def equal_button_press(self):
# Make sure a math button was clicked
if self.add_trigger or self.sub_trigger or self.mult_trigger or self.div_trigger:
if self.add_trigger:
solution = self.calc_value + float(self.entry_value.get())
elif self.sub_trigger:
solution = self.calc_value - float(self.entry_value.get())
elif self.mult_trigger:
solution = self.calc_value * float(self.entry_value.get())
else:
solution = self.calc_value / float(self.entry_value.get())
print(self.calc_value, " ", float(self.entry_value.get()),
" ", solution)
# Clear the entry box
self.number_entry.delete(0, "end")
self.number_entry.insert(0, solution)
def __init__(self, root):
# Will hold the changing value stored in the entry
self.entry_value = StringVar(root, value="")
# Define title for the app
root.title("Calculator")
# Defines the width and height of the window
root.geometry("630x220")
# Block resizing of Window
# root.resizable(width=False, height=False)
# Customize the styling for the buttons and entry
style = ttk.Style()
style.configure("TButton",
font="Serif 15",
padding=10)
style.configure("TEntry",
font="Serif 18",
padding=10)
# Create the text entry box
self.number_entry = ttk.Entry(root,
textvariable=self.entry_value, width=50)
self.number_entry.grid(row=0, columnspan=4)
# ----- 1st Row -----
self.button7 = ttk.Button(root, text="7", command=lambda: self.button_press('7')).grid(row=1, column=0)
self.button8 = ttk.Button(root, text="8", command=lambda: self.button_press('8')).grid(row=1, column=1)
self.button9 = ttk.Button(root, text="9", command=lambda: self.button_press('9')).grid(row=1, column=2)
self.button_div = ttk.Button(root, text="/", command=lambda: self.math_button_press('/')).grid(row=1, column=3)
# ----- 2nd Row -----
self.button4 = ttk.Button(root, text="4", command=lambda: self.button_press('4')).grid(row=2, column=0)
self.button5 = ttk.Button(root, text="5", command=lambda: self.button_press('5')).grid(row=2, column=1)
self.button6 = ttk.Button(root, text="6", command=lambda: self.button_press('6')).grid(row=2, column=2)
self.button_mult = ttk.Button(root, text="*", command=lambda: self.math_button_press('*')).grid(row=2, column=3)
# ----- 3rd Row -----
self.button1 = ttk.Button(root, text="1", command=lambda: self.button_press('1')).grid(row=3, column=0)
self.button2 = ttk.Button(root, text="2", command=lambda: self.button_press('2')).grid(row=3, column=1)
self.button3 = ttk.Button(root, text="3", command=lambda: self.button_press('3')).grid(row=3, column=2)
self.button_add = ttk.Button(root, text="+", command=lambda: self.math_button_press('+')).grid(row=3, column=3)
# ----- 4th Row -----
self.button_clear = ttk.Button(root, text="AC", command=lambda: self.button_press('AC')).grid(row=4, column=0)
self.button0 = ttk.Button(root, text="0", command=lambda: self.button_press('0')).grid(row=4, column=1)
self.button_equal = ttk.Button(root, text="=", command=lambda: self.equal_button_press()).grid(row=4, column=2)
self.button_sub = ttk.Button(root, text="-", command=lambda: self.math_button_press('-')).grid(row=4, column=3)
# Get the root window object
root = Tk()
# Create the calculator
calc = Calculator(root)
# Run the app until exited
root.mainloop()
assignment1/testbankaccount.py
import unittest
from bankaccount import BankAccount
class TestBankAcount(unittest.TestCase):
def setUp(self):
# Create a test BankAccount object
self.account = BankAccount()
# Provide it with some property values
self.account.balance = 1000.0
def test_legal_deposit_works(self):
# Your code here to test that depsositing money using the account's
# 'deposit_funds' function adds the amount to the balance.
curent_val = self.account.balance
self.account.deposit_funds(100)
self.assertEqual(self.account.balance, curent_val + 100)
def test_illegal_deposit_raises_exception(self):
# Your code here to test that depositing an illegal value (like 'bananas'
# or such - something which is NOT a float) results in an exception being
# raised.
self.assertRaises(ValueError, self.account.deposit_funds(-100))
self.assertRaises(ValueError,self.account.deposit_funds('abc'))
def test_legal_withdrawal(self):
# Your code here to test that withdrawing a legal amount subtracts the
# funds from the balance.
curent_val = self.account.balance
withraw = len(self.account.transaction_list)
self.account.withdraw_funds(100)
self.assertGreater(len(self.account.transaction_list),withraw)
self.assertLessEqual(self.account.balance, curent_val)
def test_illegal_withdrawal(self):
# Your code here to test that withdrawing an illegal amount (like 'bananas'
# or such - something which is NOT a float) raises a suitable exception.
self.assertRaises(ValueError, self.account.withdraw_funds('banana'))

def test_insufficient_funds_withdrawal(self):
# Your code here to test that you can only withdraw funds which are available.
# For example, if you have a balance of 500.00 dollars then that is the maximum
# that can be withdrawn. If you tried to withdraw 600.00 then a suitable exception
# should be raised and the withdrawal should NOT be applied to...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here