-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATM.py
75 lines (74 loc) · 2.75 KB
/
ATM.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
#ATM
from datetime import datetime
class ATM:
def __init__(self):
self.money=50000 #Initial Bank balance
self.pin=0000 #Initial PIN
self.tr=[]
def withdraw(self,wd):
p=int(input("Enter the pin : "))
if(p==self.pin):
if(self.money>wd):
self.money=self.money-wd
x=datetime.now()
print("Balance amount is : {0} Rs Transaction time : {1}\n".format(self.money,x))
wd= f'{x} -{wd} Rs'
self.tr.append(wd)
else:
print("Insufficient\n")
else:
print("WRONG PIN")
def deposit(self,dp):
p=int(input("Enter the pin : "))
if(p==self.pin):
self.money=self.money+dp
x=datetime.now()
print("Balance amount is : {0} Rs Transaction time : {1}\n".format(self.money,x))
dp= f'{x} +{dp} Rs'
self.tr.append(dp)
else:
print("WRONG PIN\n")
def changepin(self):
k=int(input("Enter the previous pin : "))
if(k==self.pin):
self.pin=int(input("Enter the new pin : "));
l=int(input("Confirm the PIN : "));
x=datetime.now()
if(self.pin==l):
print("PIN successfully updated !! Updated time : {0}\n\n".format(x))
j= f'{x} PIN updated'
self.tr.append(j)
else:
print("Try Again !!\n")
else:
print("WRONG PIN\n")
def transaction(self):
k=int(input("Enter the PIN : "))
print(" Transaction history ")
if(k==self.pin):
if(len(self.tr)!=0):
print("|----------------------------------------------------------------|")
for i in range(len(self.tr)):
print(" {0}) {1} ".format(i+1,self.tr[i]))
print("|----------------------------------------------------------------|")
print(" Present balance :",self.money," Rs")
print("\n")
else:
print("Empty Record\n")
else:
print("WRONG PIN\n")
x=ATM()
for i in range(100):
c=int(input("1)Withdraw money\n2)Deposit money\n3)Change the pin\n4)Transaction History\n5)Exit\n\nEnter the option you need : "))
if(c==1):
wd=int(input("Enter the amount to withdraw : "))
x.withdraw(wd)
if(c==2):
dp=int(input("Enter the amount to deposit : "))
x.deposit(dp)
if(c==3):
x.changepin()
if(c==4):
x.transaction()
if(c==5):
exit(0)