forked from blksail-edu/python-refresher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank.py
28 lines (24 loc) · 1 KB
/
bank.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Account:
def __init__ (self,balance,name,number):
"""takes in balance, name, and account#"""
self.balance = balance
self.name = name
self.number = number
#self.e = 9
def withdraw(self, amount):
"""Subtracts amount specifed from balance"""
if amount < 0 or self.balance - amount < 0: #raise an error and stop the function if something is wrong
raise ValueError('Amount drawn or resulting balance < 0')
return
self.balance -= amount
def deposit(self, amount):
"""adds amount specifed to balance"""
if amount < 0 : #raise an error and stop the function if something is wrong
raise ValueError('Amount depositied < 0')
return
self.balance += amount
def __str__(self):
return (f'Balance: {self.balance} name: {self.name} account #: {self.number}')
#print("test on main!")
if __name__ == "__main__":#run only if this file is __main__
print("test on main!")