Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def __create_card(self):
- random.seed(random.randint(0, 5000))
- card = 4000000000000000 + random.randint(0000000000, 9999999999)
- pin = (random.randint(0, 9999))
- pin = str(pin).zfill(4)
- self.__converted_list_of_numbers = list(map(int, list(str(card))))[::-1]
- self.__last_digit_card, self.__card_number_sum = 0, 0
- for num in range(0, len(self.__converted_list_of_numbers)):
- if not num == 0:
- if num % 2 != 0:
- self.__card_number_sum += self.__converted_list_of_numbers[num] * 2 - 9 \
- if self.__converted_list_of_numbers[num] * 2 > 9 else \
- self.__converted_list_of_numbers[num] * 2
- else:
- self.__card_number_sum += self.__converted_list_of_numbers[num]
- else:
- self.__last_digit_card = self.__converted_list_of_numbers[num]
- if (self.__card_number_sum + self.__last_digit_card) % 10 == 0:
- self.__function_selection = self.add(pin, card)
- else:
- self.__function_selection = self.__create_card()
- return self.__function_selection
- def add(self, pin, card):
- cur = self.conn.cursor()
- cur.execute("select id from card where number=?", (str(card),))
- data = cur.fetchall()
- print(data)
- if not data:
- self.__accounts[str(card)] = int(pin)
- self.conn.execute('INSERT INTO card (number, pin) values( ?, ?)', (str(card), int(pin)))
- print(f"""
- Your card has been created
- Your card number:
- {card}
- Your card PIN:
- {pin}""")
- self.conn.commit()
- return self.main_menu()
- def authorization(self):
- for _ in iter(int, 1):
- check_login = input("""
- Enter your card number:
- """)
- check_pin = input("""Enter your PIN:
- """)
- if check_login.isdigit() and check_pin.isdigit():
- check_pin = int(check_pin)
- if self.__accounts.get(check_login) == check_pin:
- print("""
- You have successfully logged in!""")
- self.__function_selection = self.user_account()
- else:
- print("""
- Wrong card number or PIN!""")
- self.__function_selection = self.main_menu()
- return self.__function_selection
- else:
- continue
Advertisement
Add Comment
Please, Sign In to add comment