Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Need help with this asap. Date: Tue, 12 Jan 2016 13:12:43 +0100 Organization: None Lines: 40 Message-ID: References: <1452577684.494943577@f402.i.mail.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 0GIDhCB7GmixPZyaRaFzrwTudvC4eSFvq88LTS1/R8rQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'amount:': 0.07; 'constructor': 0.07; 'subject:help': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subclass': 0.09; 'accordingly.': 0.13; 'def': 0.13; 'assigns': 0.16; 'bankaccount': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'withdrawal': 0.16; 'wrote:': 0.16; 'integer': 0.18; '(in': 0.18; 'do.': 0.22; 'suppose': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:m 30': 0.27; 'specify': 0.27; 'class.': 0.30; 'initially': 0.30; 'error.': 0.31; 'skip:_ 10': 0.32; 'class': 0.33; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:org': 0.37; 'minimum': 0.38; 'takes': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'still': 0.40; 'received:de': 0.40; 'called': 0.40; 'deposit': 0.61; 'subject:Need': 0.61; 'balance': 0.64; 'python-list': 0.66; 'account': 0.66; 'balance.': 0.84; 'subject:this': 0.85 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd8ad4.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101535 ifeanyioprah--- via Python-list wrote: > 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"` Return or print? You print. > Create a subclass MinimumBalanceAccount of the BankAccount class. I would suppose that such a MinimumBalanceAccount needs a way to specify the minimum balance (in the initializer) and to ensure (both initially and in the withdraw() method) that the account actually has that minimum balance. > 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) >