Untitled
unknown
plain_text
a year ago
1.1 kB
4
Indexable
''' Bank example: - create client (name, age ) - withdrow - deposite - show details - show balance ''' class User: def __init__(self, name, age): print(f'welcome {name}') self.name = name self.age = age def show_details(self): print(f'Name : {self.name}') print(f'Age : {self.age}') class Bank(User): def __init__(self, name, age, transactions=[]): super().__init__(name, age) self.balance = 0 self.transaction_list = transactions def withdrow(self, amount): if amount > self.balance: print(f'you don not have enough balance : {self.balance}') return self.balance -= amount self.show_balance() def deposite(self, amount): self.balance += amount self.show_balance() def show_balance(self): print(f'Your current balance : {self.balance}') c1 = Bank('Artur', 23) c1.withdrow(100) c1.show_details() c1.show_balance()
Editor is loading...
Leave a Comment