Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bankaccount
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Account:
def __init__(self, filepath):
self.filepath=filepath
with open(filepath, 'r') as file:
self.balance = int(file.read())
def withdraw(self, amount):
self.balance=self.balance - amount
def deposit(self,amount):
self.balance=self.balance + amount

def commit(self):
with open(self.filepath,'w') as file:
file.write(str(self.balance))
class Checking(Account):
def __init__(self,filepath, fee):
Account.__init__(self,filepath)
self.fee=fee
def transfer(self,amount):
self.balance=self.balance-amount-self.fee


"""checking = Checking("balance.txt", 2)
#checking.deposit(10)
checking.transfer(10)
print("available balance:",checking.balance)
checking.commit()"""

account = Account("balance.txt")
print("total balance:",account.balance)
account.withdraw(90)
account.deposit(10)
print("available balance:",account.balance)
account.commit()