class Customer: """ Customer attributes are firstname, lastname, pin, balance, id""" def __init__(self, firstname, lastname, id): self.firstname = firstname self.lastname = lastname self.id = id self._pin = '1234' self._balance = 0.0 def __str__(self): return self.firstname + ' ' + self.lastname + ': ' + str(self._balance) def deposit(self, amount): """ Deposits money into the customers account """ self._balance += amount def validPin(self, pin): """ Check and see if the pin supplied is correct. Returns True or False""" if pin == self._pin: return True else: return False def withdraw(self, amount, pin): """ User must supply the correct the correct pin. Then user must have sufficient funds. if not, return 0""" if self.validPin(pin): #check if there is enough money if amount <= self._balance: self._balance -= amount return amount else: print('Insufficient funds') return 0 else: print('Invalid Pin') return 0 def setPin(self,oldpin,newpin): """ Checks to see if the old pin is valid. If so, then set the pin equal to the new pin""" pass import copy class Bank: """ Bank has customers, which we store as dictionary, name, cash, debt""" def __init__ (self, name): self.name = name self.customers = dict() self.cash = 0.0 self.debt = 0.0 def __str__(self): return self.name def addCustomer(self, customer): self.customers[customer.id] = customer def deposit(self, id, amount): cust = copy.copy( self.customers[id] ) cust.deposit(amount) self.customers[id] = copy.copy(cust) def Simulation(): #Creates the bank bank = Bank('cs101') #create a customer c1 = Customer('Jason','Grant',1) bank.addCustomer(c1) bank.deposit(1,50)