SHOW:
|
|
- or go back to the newest paste.
1 | - | def glowne_menu(): |
1 | + | def main_menu(): |
2 | - | print("Wybierz opcje:") |
2 | + | print("Select an option:") |
3 | - | print("1. Wpłata") |
3 | + | print("1. Deposit") |
4 | - | print("2. Wypłata") |
4 | + | print("2. Withdrawal") |
5 | - | print("3. Sprawdzenie stanu konta") |
5 | + | print("3. Check account balance") |
6 | - | print("4. Zakończ") |
6 | + | print("4. Exit") |
7 | - | print("5. Wyświetlenie histori operacji") |
7 | + | print("5. Show transaction history") |
8 | ||
9 | - | def pobierz_wybor_klienta(): |
9 | + | def get_customer_choice(): |
10 | - | return int(input("twój wybór to: ")) |
10 | + | return int(input("your choice is: ")) |
11 | ||
12 | - | def pobierz_kwote(tekst): |
12 | + | def get_amount(text): |
13 | - | return float(input(tekst)) |
13 | + | return float(input(text)) |
14 | ||
15 | - | def pokaz_stan_konta(saldo): |
15 | + | def show_account_balance(balance): |
16 | - | print(f"Stan konta wynosi {saldo} złotych") |
16 | + | print(f"The account balance is {balance}") |
17 | ||
18 | - | def wplata(saldo): |
18 | + | |
19 | - | kwota_wplaty = pobierz_kwote("Ile chcesz wpłacić") |
19 | + | def deposit(balance): |
20 | - | saldo = saldo + kwota_wplaty |
20 | + | deposit_amount = get_amount("How much would you like to deposit?") |
21 | - | pokaz_stan_konta(saldo) |
21 | + | balance = balance + deposit_amount |
22 | - | return saldo |
22 | + | show_account_balance (balance) |
23 | return balance | |
24 | ||
25 | - | def wyplata(saldo): |
25 | + | |
26 | - | kwota_wyplaty = pobierz_kwote("Ile chcesz wypłacić") |
26 | + | def withdrawal(balance): |
27 | - | if kwota_wyplaty > saldo: |
27 | + | withdrawal_amount = get_amount("How much would you like to withdraw?") |
28 | - | print("Operacja nie udana, za mało środków na koncie") |
28 | + | if withdrawal_amount > balance: |
29 | - | return saldo |
29 | + | print("Operation failed, not enough funds on the account ") |
30 | return balance | |
31 | - | saldo -= kwota_wyplaty |
31 | + | |
32 | - | print(f"Wypłacono {kwota_wyplaty} złotych") |
32 | + | balance -= withdrawal_amount |
33 | - | return saldo |
33 | + | print(f"The amount withdrawn {withdrawal_amount}") |
34 | return balance | |
35 | ||
36 | - | def pobierz_dane(dana): |
36 | + | |
37 | - | return input(f"Podaj numer {dana}: ") |
37 | + | |
38 | def get_data(data): | |
39 | - | def sprawdz_zgodnosc_danych(baza, karta, pin): |
39 | + | return input(f"Enter {data} number:") |
40 | - | for klient in baza: |
40 | + | |
41 | - | if klient[0] == karta: |
41 | + | def check_data_validity(database, card, pin): |
42 | - | return klient[1] == pin |
42 | + | for customer in database: |
43 | if customer[0] == card: | |
44 | return customer[1] == pin | |
45 | return False | |
46 | - | def pobierz_stan_konta(baza, karta): |
46 | + | |
47 | - | for klient in baza: |
47 | + | |
48 | - | if klient[0] == karta: |
48 | + | def get_account_balance(database, card): |
49 | - | return klient[2] |
49 | + | for customer in database: |
50 | if customer[0] == card: | |
51 | return customer[2] | |
52 | - | def aktualizuj_historie_klienta(baza, karta, operacja): |
52 | + | |
53 | - | for klient in baza: |
53 | + | |
54 | - | if klient[0] == karta: |
54 | + | |
55 | - | klient[3].append(operacja) |
55 | + | |
56 | def update_customer_history(database, card, transaction): | |
57 | - | def pokaz_historie_klienta(baza, karta): |
57 | + | for customer in database: |
58 | - | for klient in baza: |
58 | + | if customer[0] == card: |
59 | - | if klient[0] == podana_karta: |
59 | + | customer[3].append(transaction) |
60 | - | for i in range(len(klient[3])): |
60 | + | |
61 | - | print(f'{i+1}. {klient[3][i]}') |
61 | + | def show_customer_history(database, card): |
62 | - | #powyżej nich będziemy pisać wszystkie funkcje naszego programu!!! |
62 | + | for customer in database: |
63 | - | wybor = 0 |
63 | + | if customer[0] == card_provided: |
64 | - | saldo = 0 |
64 | + | for i in range(len(customer[3])): |
65 | - | #KARTA = "0001" |
65 | + | print(f'{i+1}. {customer[3][i]}') |
66 | ||
67 | - | KLIENCI = [ |
67 | + | #we write all the functions of our program above!!! |
68 | choice = 0 | |
69 | balance = 0 | |
70 | #CARD = "0001" | |
71 | #PIN = "1234" | |
72 | - | #poniżej będzie główna pętla programu |
72 | + | CUSTOMERS = [ |
73 | - | podana_karta = pobierz_dane("karty") |
73 | + | |
74 | - | podany_pin = pobierz_dane("PIN") |
74 | + | |
75 | - | if sprawdz_zgodnosc_danych(KLIENCI, podana_karta, podany_pin): |
75 | + | |
76 | - | saldo = pobierz_stan_konta(KLIENCI, podana_karta) |
76 | + | |
77 | - | while wybor != 4: |
77 | + | #below is the main loop of the program |
78 | - | glowne_menu() |
78 | + | card_provided = get_data("card") |
79 | - | wybor = pobierz_wybor_klienta() |
79 | + | pin_provided = get_data("PIN") |
80 | - | if wybor == 1: |
80 | + | |
81 | - | saldo = wplata(saldo) |
81 | + | if check_data_validity(CUSTOMERS, card_provided, pin_provided): |
82 | - | aktualizuj_historie_klienta(KLIENCI,podana_karta, "Wpłata") |
82 | + | balance = get_account_balance(CUSTOMERS, card_provided) |
83 | while choice != 4: | |
84 | - | elif wybor == 2: |
84 | + | main_menu() |
85 | - | saldo = wyplata(saldo) |
85 | + | choice = get_customer_choice() |
86 | - | aktualizuj_historie_klienta(KLIENCI,podana_karta, "Wypłata") |
86 | + | if choice == 1: |
87 | balance = deposit(balance) | |
88 | - | elif wybor == 3: |
88 | + | update_customer_history(CUSTOMERS, card_provided, "Deposit") |
89 | - | pokaz_stan_konta(saldo) |
89 | + | |
90 | - | aktualizuj_historie_klienta(KLIENCI,podana_karta, "Wyświetlenie salda") |
90 | + | elif choice == 2: |
91 | balance = withdrawal(balance) | |
92 | - | elif wybor == 4: |
92 | + | update_customer_history(CUSTOMERS, card_provided, "Withdrawal") |
93 | - | print("Wyłączanie bankomatu") |
93 | + | |
94 | elif choice == 3: | |
95 | - | elif wybor == 5: |
95 | + | show_account_balance(balance) |
96 | - | pokaz_historie_klienta(KLIENCI,podana_karta) |
96 | + | update_customer_history(CUSTOMERS, card_provided, "Show balance") |
97 | pass | |
98 | elif choice == 4: | |
99 | - | print("niepoprawne dane") |
99 | + | print("Shutting down the ATM") |
100 | pass | |
101 | elif choice == 5: | |
102 | show_customer_history(CUSTOMERS, card_provided) | |
103 | - | print("błąd logowania") |
103 | + | |
104 | else: | |
105 | print("Invalid data") | |
106 | pass | |
107 | pass | |
108 | else: | |
109 | print("Login error") | |
110 | ||
111 | ||
112 | ||
113 |