Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101525

Need help with this asap.

From ifeanyioprah@yahoo.com
Newsgroups comp.lang.python
Subject Need help with this asap.
Date 2016-01-12 08:48 +0300
Message-ID <mailman.43.1452587147.13488.python-list@python.org> (permalink)

Show all headers | View raw


Create a class called BankAccount
Create a constructor that takes in an integer and assigns this to a `balance` property.
Create a method called `deposit` that takes in cash deposit amount and updates the balance accordingly.
Create a method called `withdraw` that takes in cash withdrawal amount and updates the balance accordingly. if amount is greater than balance return `"invalid transaction"`
Create a subclass MinimumBalanceAccount of the BankAccount class.
This was my solution and I still got error. What should I do.
class BankAccount: 
    def __init__(self, initial_amount): 
        self.balance = initial_amount 
    def deposit(self, amount): 
        self.balance += amount 
    def withdraw(self, amount): 
        if self.balance>= amount: 
            self.balance  -=  amount 
        else: 
          print('invalid transaction') 
a1 = BankAccount (90) 
a1.deposit(90) 
a1.withdraw(40) 
a1.withdraw(1000) 
class MinimumBalanceAccount(BankAccount): 
    def __init__(self): 
        BankAccount.__init__(self) 

Please help me.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Need help with this asap. ifeanyioprah@yahoo.com - 2016-01-12 08:48 +0300

csiph-web