Advertisement
jimMoonrock

Untitled

Apr 26th, 2021
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. import random
  2.  
  3. class CardAnatomy:
  4.  
  5.     def __init__(self):
  6.         self.date_base = {}
  7.         self.user_balance = 0
  8.  
  9.     def main(self):
  10.         command = int(input("1. Create an account\n2. Log into account\n0. Exit\n>"))
  11.         print(" ")
  12.         self.check_command(command)
  13.  
  14.     def check_command(self, command):
  15.         if command == 1:
  16.             return self.create()
  17.         elif command == 2:
  18.             return self.login()
  19.         elif command == 0:
  20.             return self.exit()
  21.  
  22.     def create(self):
  23.         random.seed(0)
  24.         user_card = (4000000000000000 + int('{:10d}'.format(random.randrange(0000000000, 9999999999))))
  25.         user_pin_card = '{:04d}'.format(random.randrange(0000, 9999))
  26.         if user_card not in self.date_base:
  27.             self.date_base[user_card] = user_pin_card
  28.             print(f"Your card has been created\nYour card number:\n{user_card}\nEnter your PIN:\n{user_pin_card}")
  29.             print(" ")
  30.             self.main()
  31.         else:
  32.             self.main()
  33.  
  34.     def login(self):
  35.         check_card_number = int(input("Enter your card number:\n>"))
  36.         pin_code_check = input("Enter your PIN:\n>")
  37.         if self.date_base[check_card_number] == pin_code_check:
  38.             print(" ")
  39.             print("You have successfully logged in!")
  40.             print(" ")
  41.             self.card_actions()
  42.         elif self.date_base[check_card_number] == pin_code_check:
  43.             self.main()
  44.         else:
  45.             print("Bye!")
  46.  
  47.  
  48.     def card_actions(self):
  49.         select_after_authorization = int(input("1. Balance\n2. Log out\n0. Exit\n>"))
  50.         if select_after_authorization == 1:
  51.             print(self.user_balance)
  52.             self.card_actions()
  53.         elif select_after_authorization == 2:
  54.             self.main()
  55.         elif select_after_authorization == 0:
  56.             print("Bye!")
  57.  
  58.    
  59.  
  60. ron = CardAnatomy()
  61. print(ron.main())
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement