-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank.py
76 lines (70 loc) · 1.87 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
##oop bank example
from os import system
from time import sleep
class Bank:
def __init__(self,money):
page="""
XXXXX X XX X X X
X X X X X X X X XX
XXXXX XXXXX X X X XXX
X X X X X X X X XX
XXXXXX X X X XX X X
WELCOME BANK
"""
self.page1="""
1:MONEY ADD
2:MONEY TAKE
3:ABOUT
4:EXİT
"""
print(page)
self.money=money
sleep(3)
system("cls")
self.start()
def start(self):
sleep(2)
system("cls")
print(self.page1)
print("do you want to do another action ?")
try:
answer=int(input('please click key'))
except:
print("not found")
self.start()
if answer==1:
self.add()
elif answer==2:
self.take()
elif answer==3:
self.about()
elif answer==4:
self.finish()
else:
print("not found")
def add(self):
try:
x=abs(int(input('please money add')))
except:
print("not found")
self.add()
self.money+=x
print(f"money {self.money} $")
self.start()
def take(self):
try:
x=abs(int(input('please money take')))
except:
print("not found")
self.take()
if x<=self.money:
self.money-=x
self.start()
def about(self):
print(f"money: {self.money} $")
self.start()
def finish(self):
print("GOOD BYE BANK")
exit()
if __name__=="__main__":
Bank(200)