Help me please i'm new to programming

0 Chadwyk Prince · April 25, 2015
Guys please help i'm stuck making this banking system and i have no clue where i went wrong

class Bank_Account: # Creates the Class Bank Account

    def __init__(self, Account_Number, Account_Owner, Balance): # Creates an an account with no money in it's balance
        self.Account_Number = Account_Number
        self.Account_Owner = Account_Owner
        self.Balance = Balance
    def makeAccount1(self, Account_Number, Account_Owner): # Creates an an account with no money in it's balance
        Balance = 0
        return [self.Account_Number, self.Account_Owner, Balance]

    def makeAccount2(self, Account_Number, Account_Owner, Starting_Balance): # Creates an account with a inputed starting balance
         Balance = 0
         Balance += Starting_Balance
         return [self.Account_Number, self.Account_Owner, self.Balance]

    def getAcctNumber(self): # Displays the account number
        return self.Account_Number[0]

    def getAcctName(self): # Displays the account name
        return self.Account_Owner[0][1]

    def getAcctBalance(self): # Displays the account balance
        return self.Balance[0][2]

    def changeName(self,Name): # Changes the name of the account only if a different name is entered 
        if self.Account_Owner == Name:
            return "Error, the name is the same!"
        elif self.Account_Owner != Name:
            self.Account_Owner = Name
            return Name

    def isAccount(Bank_Account): # Checks if the account number enter exists and prints true or false accordingly
        if Bank_Account[0] == type(''):
            return False
            return True

    def isBalanceEnough(self, Bank_Account, Amount):  # Finds the matching account and checks if enough money is in the account balance
        if Amount < self.getAcctBalance():
            return True
            return False

    def Withdraw(self,Amount): # Withdraws from the account
        if self.Balance[0][2] - Amount >= 0:
            self.Balance = self.Balance-Amount
            return "Withdrawal Successful!"
            return "Withdrawal Unsuccessful!"

    def Deposit(self,Amount): # Deposits into the account
        self.Balance[0][2] += Amount
        return "Deposit Successful"

    def transfer(self,Amount,Bank_Account1,Bank_Account2):# Transfers money from one valid account to another  
        if isAccount(Bank_Account1) and isAccount(Bank_Account2):
            Bank_Account1[0][2] = Bank_Account1[0][2] - Amount
            Bank_Account2[0][2] = Bank_Account2[0][2] + Amount
            return "Transfer Successful!"

class Account_Collection(Bank_Account): # A stack of created accounts
     def __init__(self): 
     def isEmpty(self): # Checks if the Account Collection is empty
         return self.size() == 0   

     def Add_Account(self, *acct):  # Adds a new account to the stack

     def Remove_Account(self): # Removes an account from the stack
         return self.AcctSystem.pop(-1)  

     def Size(self): # Checks the size of the stack
         return len(self.AcctSystem) 

x = Bank_Account # Allows you to type x instead of Bank_Account in the python shell.

y = Main_Menu # Allows you to type y instead of Main_Menu in the python shell

z = Account_Collection # Allows you to type z instead of Bank_Account in the python shell.

Post a Reply


Oldest  Newest  Rating
0 alex constantin · April 25, 2015
Objects need parenthesis at the end:

x = Bank_Account(parameters)
0 Chadwyk Prince · April 27, 2015
i get this error when i use parenthesis:

NameError: name 'Account_Number' is not defined
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator