-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop_detailed.py
More file actions
66 lines (56 loc) · 1.78 KB
/
Copy pathoop_detailed.py
File metadata and controls
66 lines (56 loc) · 1.78 KB
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
class Atm:
def __init__(self):
self.__pin = ""
self.__balance = 0
self.__menu()
def create_pin(self):
self.__pin = input("Enter new pin: ")
print("Pin created successfully")
def check_balance(self):
pin = input("Enter pin: ")
if pin == self.__pin:
print(f"Your balance is {self.__balance}")
else:
print("Invalid pin")
def withdraw(self):
pin = input("Enter pin: ")
if pin == self.__pin:
amount = int(input("Enter amount to withdraw: "))
if amount <= self.__balance:
self.__balance -= amount
print(f"Withdraw successful. Balance: {self.__balance}")
else:
print("Insufficient balance")
else:
print("Invalid pin")
def deposit(self):
pin = input("Enter pin: ")
if pin == self.__pin:
amount = int(input("Enter amount to deposit: "))
self.__balance += amount
print(f"Deposit successful. Balance: {self.__balance}")
else:
print("Invalid pin")
def __menu(self):
while True:
choice = input("""
1. Create Pin
2. Check Balance
3. Withdraw
4. Deposit
5. Exit
Choose an option: """)
if choice == "1":
self.create_pin()
elif choice == "2":
self.check_balance()
elif choice == "3":
self.withdraw()
elif choice == "4":
self.deposit()
elif choice == "5":
print("Thank you for using ATM")
break
else:
print("Invalid choice")
atm = Atm()