# Bank account object - it's just a collection of variables. class BankAccount(object): name = "" balance = 0 pin = "" # The class "constructor" - It's actually an initializer def __init__(self, name, balance, pin): self.name = name self.balance = balance self.pin = pin # How we print a string def __repr__(self): return "name: " + self.name + "\nbalance : " + str(self.balance) + "\npin: " + self.pin; # Makes a bank account (calls the "constructor"). def make_bank_account(name, balance, pin): return BankAccount(name, balance, pin); # Where we do out work. def banking(): name = ""; # Get the user's name, save it in the "name" variable. pin = ""; # Have the user choose a pin, save it in the "pin" variable. # Make sure it has at least 4 characters. while(len(pin) < 4): # Fill this bit in! break; # Delete this line once you put in your own code # This makes a new bank account object, and prints it out. bankAccount = make_bank_account(name, 0, pin); print("You have a bank account!"); print(bankAccount); # Now we can start banking. # This means it will loop forever. while(True): break; # Delete this line once you put in your own code # Ask the user if they want to pay in or withdraw money. # Ask for the amount. # If they are withdrawing, take that amount away from their balance. # If they are paying in, add that money to their balance. # Print out their new balance. # main method, called when you run the program. if __name__=='__main__': banking();