Answer To: ITECH1400 – Foundations of Programming – SEM3/18 School of Science, Engineering and Information...
Ximi answered on Jan 31 2021
MoneyManager/testmoneymanager.py
MoneyManager/moneymanager.py
class MoneyManager(object):
def __init__(self, username, password, balance, transaction_list):
self.username = username
self.password = password
self.balance = balance
self.transaction_list = transaction_list
def add_entry(self, entry_type, amount):
entries = ["food", "rent", "bills", "entertainment", "other"]
if entry_type not in entries:
raise ValueError("Cannot have this entry.")
if int(self.balance)-int(amount) < 0:
raise ValueError("Amount exceeds your balance")
self.transaction_list.append((entry_type, amount))
def deposit_funds(self,amount):
self.transaction_list.append(("Deposit", amount))
self.balance = str(int(self.balance)+int(amount))
def get_transaction_string(self):
string = ["\n{}\n{}".format(e, a) for e,a in self.transaction_list]
return string
def save_to_file(self):
string = self.get_transaction_string()
with open(self.username+".txt", "w") as f:
f.write(self.username+"\n")
f.write(self.password+"\n")
f.write(self.balance)
for s in string:
f.write(s)
__MACOSX/MoneyManager/._moneymanager.py
MoneyManager/__pycache__/moneymanager.cpython-37.pyc
MoneyManager/test.py
from tkinter import Tk, W, E
from tkinter.ttk import Frame, Button, Entry, Style, Label
class Example(Frame):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.master.title("FedUni Money Manager")
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 10')
Style().configure("Login.TButton", background="#ccc")
self.columnconfigure(0, pad=3)
self.columnconfigure(1, pad=3)
self.columnconfigure(2, pad=3)
self.rowconfigure(0, pad=3)
self.rowconfigure(1, pad=3)
self.rowconfigure(2, pad=3)
self.rowconfigure(3, pad=3)
self.rowconfigure(4, pad=3)
Label(self, text='FedUni Money Manager',font=("Helvetica", 22)).grid(row=0, column=0, columnspan=3)
Label(self, text='Username/ PIN').grid(row=1, column=0)
Entry(self, width=20).grid(row=1, column=1)
Entry(self, width=20).grid(row=1, column=2)
Button(self, text='1', width=10,).grid(row=2,column=0)
Button(self, text='2', width=10).grid(row=2,column=1)
Button(self,text='3', width=10).grid(row=2,column=2)
Button(self,text='4', width=10).grid(row=3,column=0)
Button(self,text='5', width=10).grid(row=3,column=1)
Button(self,text='6', width=10).grid(row=3,column=2)
Button(self,text='7', width=10).grid(row=4,column=0)
Button(self,text='8', width=10).grid(row=4,column=1)
Button(self,text='9',...