在python中编码最低余额银行帐户

时间:2019-05-12 16:16:02

标签: python-3.x jupyter-notebook

需要创建一个从母银行帐户类继承的最低余额帐户。

还需要重写提现方法以检查是否维持最低余额

class  bankaccount:
def __init__(self,name,accountno, bal=0):
    self.name= name
    self.accountno=accountno
    self.bal=bal
def deposit(self,amount):
    self.bal+=amount        
    print ('dear',self.name, 'having account no',self.accountno,'you have deposited',amount,  '\n remaining balance',self.bal )
def withdraw(self,amount):        
    if self.bal>=amount:
        self.bal-=amount
        print('your withdrawl of rs',amount, "is succesful")
    else:
        print('insufficiant balance')
def checkbal(self):
    print ("\n Net Available Balance =", self.bal)

class minbalbankaccount(bankaccount):
def __init__(self, minimumbal):
    bankaccount.__init__(self)
    self.minimumbal= minimumbal
def withdraw(self, amount):
    if self.bal - amount < self.minimumbal:
        print ('Sorry, minimum balance must be maintained.')
    else:
        bankaccount.withdraw(self,amount)
        print('remaining bal',self.bal)

获取错误 init ()缺少2个必需的位置参数:“ name”和“ accountno”

0 个答案:

没有答案