From d4008387c23ccc46f02897d9629a305378b81cd3 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Wed, 1 Oct 2025 16:18:06 +0300 Subject: [PATCH 01/18] Create file --- task_Lab3.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 task_Lab3.py diff --git a/task_Lab3.py b/task_Lab3.py new file mode 100644 index 0000000..e69de29 From 2cd30e72c9d088d562d5c9734012fd4786892eef Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Wed, 1 Oct 2025 16:19:16 +0300 Subject: [PATCH 02/18] Move file into folder --- task_Lab3.py => Laba3/task_Lab3.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename task_Lab3.py => Laba3/task_Lab3.py (100%) diff --git a/task_Lab3.py b/Laba3/task_Lab3.py similarity index 100% rename from task_Lab3.py rename to Laba3/task_Lab3.py From aaf9422fc26f3fae03845ea8adaf61e0532d4065 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Wed, 1 Oct 2025 17:57:55 +0300 Subject: [PATCH 03/18] First steps --- Laba3/task_Lab3.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Laba3/task_Lab3.py b/Laba3/task_Lab3.py index e69de29..44f36dd 100644 --- a/Laba3/task_Lab3.py +++ b/Laba3/task_Lab3.py @@ -0,0 +1,31 @@ +def main(): + #TODO: some interface + pass + +class Bank: + def open_account(self): + pass + def close_account(self): + pass + def TopUp_account(self): + pass + def money_transfer(self): + pass + + +class BankAccount: + #TODO currency of accaount + pass + +class Client: + def __init__(self, ID): + self.ID = ID + #TODO: polya: input_ID + #TODO somehow make creation of new accounts + pass + +# >Enter your ID +# (output interface) +# add password to ID? +# +# at the end of programm ask (continue or finish?) \ No newline at end of file From 53c1f3cfddbf2fe78c26549c46604d8e45c02d28 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Tue, 7 Oct 2025 23:31:26 +0300 Subject: [PATCH 04/18] Start make bank interface --- Laba3/classes.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++ Laba3/task_Lab3.py | 37 ++++++++++------------ 2 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 Laba3/classes.py diff --git a/Laba3/classes.py b/Laba3/classes.py new file mode 100644 index 0000000..489f157 --- /dev/null +++ b/Laba3/classes.py @@ -0,0 +1,78 @@ +class Bank: + def __init__(self, name): + self._clients = {} + self._clients_number = 0 + self._bank_name = name + pass + + def add_client(): + + pass + + def find_client(): + pass + +class BankInterface: + def __init__(self, bank): + self._bank = bank + + def Sign_in_ID(bank): #*def to create or sing in ID + while True: + + action = input("Choose action:\n 1.Sing in to ID.\n 2.Create ID") + match action: + case 1: + + pass + case 2: + + pass + case _: + print("Invalid option. Try again.") + + def sign_in(bank): + while True: + ID = input("Enter ID: ") + if bank.find_id(): + #continue + else: + print("No valid ID. Try again or create an ID.") + + while True: + action = input("1.Try again\n 2.Create new ID") + match action: + case 1: + break + case 2: + self.registration(bank) + #?return + case _: + print("Invalid option. Try again.") + + def registration(bank): + + + + + + + + +class BankAccount: + #TODO currency of accaount + pass + +class Client: + def __init__(self, ID): + self.ID = ID + def open_account(self): + pass + def close_account(self): + pass + def TopUp_account(self): + pass + def money_transfer(self): + pass + #TODO: polya: input_ID + #TODO somehow make creation of new accounts + pass \ No newline at end of file diff --git a/Laba3/task_Lab3.py b/Laba3/task_Lab3.py index 44f36dd..892935f 100644 --- a/Laba3/task_Lab3.py +++ b/Laba3/task_Lab3.py @@ -1,28 +1,25 @@ +from classes import Bank, BankAccount, Client, BankInterface + + def main(): #TODO: some interface pass -class Bank: - def open_account(self): - pass - def close_account(self): - pass - def TopUp_account(self): - pass - def money_transfer(self): - pass - - -class BankAccount: - #TODO currency of accaount - pass -class Client: - def __init__(self, ID): - self.ID = ID - #TODO: polya: input_ID - #TODO somehow make creation of new accounts - pass + + + + + + + + + + + + + + # >Enter your ID # (output interface) From f2da93614535bbc97b8bfd11c053c4de779d59a2 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Thu, 9 Oct 2025 23:54:54 +0300 Subject: [PATCH 05/18] registtration, add_client, find_client --- Laba3/classes.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 489f157..282321b 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -1,15 +1,25 @@ class Bank: + clients = {} + number_of_clients = 0 + def __init__(self, name): - self._clients = {} - self._clients_number = 0 - self._bank_name = name + self.clients = {} + self.number_of_clients = 0 + self.bank_name = name pass - def add_client(): - + def add_client(self, ID, name): + ID = self.number_of_clients #TODO реализоаать ID + new_client = Client(ID, name) #?надо? + self.clients[ID] = name + self.number_of_clients += 1 pass - def find_client(): + def find_client(self, ID): + for client in self.clients: + if ID in client: + return True + return False pass class BankInterface: @@ -22,7 +32,7 @@ def Sign_in_ID(bank): #*def to create or sing in ID action = input("Choose action:\n 1.Sing in to ID.\n 2.Create ID") match action: case 1: - + self.sign_in(bank) pass case 2: @@ -50,7 +60,9 @@ def sign_in(bank): print("Invalid option. Try again.") def registration(bank): - + client_name = input("Enter your name and surname: ") + bank.add_client() + @@ -63,8 +75,12 @@ class BankAccount: pass class Client: - def __init__(self, ID): + + + def __init__(self, ID, name): self.ID = ID + self.name = name + def open_account(self): pass def close_account(self): From d3b858fe8c5349c9ca9a3f5d60251c1b99360953 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Fri, 10 Oct 2025 00:24:28 +0300 Subject: [PATCH 06/18] finished main_menu? --- Laba3/classes.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 282321b..d9e707a 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -8,9 +8,9 @@ def __init__(self, name): self.bank_name = name pass - def add_client(self, ID, name): + def add_client(self, name): ID = self.number_of_clients #TODO реализоаать ID - new_client = Client(ID, name) #?надо? + new_client = Client(ID, name) #?надо ли создавать объет для хранения счетов self.clients[ID] = name self.number_of_clients += 1 pass @@ -26,42 +26,46 @@ class BankInterface: def __init__(self, bank): self._bank = bank - def Sign_in_ID(bank): #*def to create or sing in ID + + #// MAIN_menu вроде готово + def MAIN_menu (self, bank): #*def to create or sing in ID while True: - action = input("Choose action:\n 1.Sing in to ID.\n 2.Create ID") + action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create ID")) match action: case 1: - self.sign_in(bank) - pass + self.sign_in(bank) #дальнейший ход интерфейса + return case 2: - - pass + self.registration(bank) #дальнейший ход интерфейса + return case _: print("Invalid option. Try again.") - def sign_in(bank): + #//тут вроже тоже всё + def sign_in(self, bank): while True: - ID = input("Enter ID: ") - if bank.find_id(): - #continue + client_ID = int(input("Enter ID: ")) #?потом string + if bank.find_id(client_ID): + #дальнейший интерфейс + return else: print("No valid ID. Try again or create an ID.") while True: - action = input("1.Try again\n 2.Create new ID") + action = int(input("1.Try again\n 2.Create new ID")) match action: case 1: - break + break #back to first cycle case 2: self.registration(bank) - #?return + #?return или сразу переход на (3) case _: print("Invalid option. Try again.") def registration(bank): client_name = input("Enter your name and surname: ") - bank.add_client() + bank.add_client(client_name) From 612c99d5170eec968454c7fd53fa8683c9caccc8 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Fri, 10 Oct 2025 20:20:44 +0300 Subject: [PATCH 07/18] create main interface for account operations --- Laba3/classes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Laba3/classes.py b/Laba3/classes.py index d9e707a..a789dfc 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -67,7 +67,24 @@ def registration(bank): client_name = input("Enter your name and surname: ") bank.add_client(client_name) +class ClientInterface: + def MAIN_not_menu(self, client): + while True: + + action = int(input("Choose action:\n 1.Open account.\n 2.Close account.\n 3.Operations with account.")) + match action: + case 1: + client.open_account() + return + case 2: + client.open_account() + return + case 3: + #next option + pass + case _: + print("Invalid option. Try again.") From 981e930326e8f5048f1dd18e9d6db19c67b358fd Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Fri, 10 Oct 2025 20:40:40 +0300 Subject: [PATCH 08/18] account operations + BankAcc constructor --- Laba3/classes.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index a789dfc..4ac57ec 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -78,26 +78,43 @@ def MAIN_not_menu(self, client): client.open_account() return case 2: - client.open_account() + client.close_account() return case 3: - #next option - pass + self.account_operations(client) + return case _: print("Invalid option. Try again.") + def account_operations(self, client): + while True: + + action = int(input("Choose action:\n 1.Top up account.\n 2.Withdraw money.\n 3.Transfer money to account.")) + match action: + case 1: + client.TopUp_account() + return + case 2: + client.withdraw_money() + return + case 3: + client.money_transfer() + return + case _: + print("Invalid option. Try again.") class BankAccount: - #TODO currency of accaount - pass + + def __init__(self, currency, money): + self.currency = currency + self.amount_of_money = money class Client: - def __init__(self, ID, name): self.ID = ID self.name = name @@ -110,6 +127,8 @@ def TopUp_account(self): pass def money_transfer(self): pass + def withdraw_money(self): + pass #TODO: polya: input_ID #TODO somehow make creation of new accounts pass \ No newline at end of file From 6bff673d4c0c252b6afe543f036c9bbb81555825 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Fri, 10 Oct 2025 22:10:37 +0300 Subject: [PATCH 09/18] some changes --- Laba3/classes.py | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 4ac57ec..10dba2d 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -10,8 +10,7 @@ def __init__(self, name): def add_client(self, name): ID = self.number_of_clients #TODO реализоаать ID - new_client = Client(ID, name) #?надо ли создавать объет для хранения счетов - self.clients[ID] = name + self.clients[ID] = Client(ID, name) self.number_of_clients += 1 pass @@ -75,10 +74,12 @@ def MAIN_not_menu(self, client): action = int(input("Choose action:\n 1.Open account.\n 2.Close account.\n 3.Operations with account.")) match action: case 1: - client.open_account() + self.openning_interface(client) + print("Account succesfully opened.") return case 2: client.close_account() + print("Account closed.") return case 3: self.account_operations(client) @@ -103,24 +104,47 @@ def account_operations(self, client): case _: print("Invalid option. Try again.") + def openning_interface(self, client): + while True: + + action = int(input("Choose currency of account:\n 1.USD.\n 2.BYN.\n 3.EUR.")) + match action: + case 1: + client.open_account("USD") + return + case 2: + client.open_account("BYN") + return + case 3: + client.open_account("EUR") + return + case _: + print("Invalid option. Try again.") + class BankAccount: - - def __init__(self, currency, money): + amount_of_money = 0 + account_number = 0 + + def __init__(self, currency): self.currency = currency - self.amount_of_money = money class Client: + accounts = [] + number_of_accounts = 0 def __init__(self, ID, name): self.ID = ID self.name = name - def open_account(self): - pass + #? get_name + def open_account(self, currency): + self.accounts[self.number_of_accounts] = BankAccount(currency) + self.number_of_accounts += 1 + def close_account(self): pass def TopUp_account(self): From c401907dbd28c8886e434796da2d8b118dc03e79 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 09:48:25 +0300 Subject: [PATCH 10/18] minor changes --- Laba3/classes.py | 21 ++++++++++++++++----- Laba3/task_Lab3.py | 23 +---------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 10dba2d..f1594f7 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -19,7 +19,6 @@ def find_client(self, ID): if ID in client: return True return False - pass class BankInterface: def __init__(self, bank): @@ -71,7 +70,8 @@ class ClientInterface: def MAIN_not_menu(self, client): while True: - action = int(input("Choose action:\n 1.Open account.\n 2.Close account.\n 3.Operations with account.")) + action = int(input("Choose action:\n 1.Open account.\n 2.Close account." \ + "\n 3.Operations with account.\n 4.Get all accounts statement")) match action: case 1: self.openning_interface(client) @@ -84,6 +84,10 @@ def MAIN_not_menu(self, client): case 3: self.account_operations(client) return + case 4: + client.accounts_statement() + print("Something") + return case _: print("Invalid option. Try again.") @@ -128,26 +132,33 @@ def openning_interface(self, client): class BankAccount: amount_of_money = 0 account_number = 0 + - def __init__(self, currency): + def __init__(self, currency, owner_ID): self.currency = currency + self.owner_ID = owner_ID class Client: - accounts = [] + accounts = {} number_of_accounts = 0 def __init__(self, ID, name): self.ID = ID self.name = name + def get_ID(self): + return self.ID + #? get_name def open_account(self, currency): - self.accounts[self.number_of_accounts] = BankAccount(currency) + self.accounts[self.number_of_accounts] = BankAccount(currency, self.ID) self.number_of_accounts += 1 def close_account(self): + #delte from dict pass def TopUp_account(self): + pass def money_transfer(self): pass diff --git a/Laba3/task_Lab3.py b/Laba3/task_Lab3.py index 892935f..8769f1f 100644 --- a/Laba3/task_Lab3.py +++ b/Laba3/task_Lab3.py @@ -1,28 +1,7 @@ -from classes import Bank, BankAccount, Client, BankInterface +from classes import Bank, BankAccount, Client, BankInterface, ClientInterface def main(): #TODO: some interface pass - - - - - - - - - - - - - - - - -# >Enter your ID -# (output interface) -# add password to ID? -# -# at the end of programm ask (continue or finish?) \ No newline at end of file From acf9566d77a14ca4fa5c501cf839d5fdcc55a423 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 09:54:44 +0300 Subject: [PATCH 11/18] remove some methods to BankAccount, create account_statement --- Laba3/classes.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index f1594f7..63c0c76 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -138,6 +138,16 @@ def __init__(self, currency, owner_ID): self.currency = currency self.owner_ID = owner_ID + def TopUp_account(self): + pass + def money_transfer(self): + pass + def withdraw_money(self): + pass + + + + class Client: accounts = {} number_of_accounts = 0 @@ -157,13 +167,7 @@ def open_account(self, currency): def close_account(self): #delte from dict pass - def TopUp_account(self): - - pass - def money_transfer(self): - pass - def withdraw_money(self): + + def account_statement(self): pass - #TODO: polya: input_ID - #TODO somehow make creation of new accounts - pass \ No newline at end of file + \ No newline at end of file From 6adb2e462974c4eb5e5fe7a95a2bbccd87f22b78 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 11:08:38 +0300 Subject: [PATCH 12/18] main() --- Laba3/classes.py | 3 ++- Laba3/task_Lab3.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 63c0c76..f84c0ea 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -40,7 +40,7 @@ def MAIN_menu (self, bank): #*def to create or sing in ID case _: print("Invalid option. Try again.") - #//тут вроже тоже всё + #//тут вроде тоже всё def sign_in(self, bank): while True: client_ID = int(input("Enter ID: ")) #?потом string @@ -57,6 +57,7 @@ def sign_in(self, bank): break #back to first cycle case 2: self.registration(bank) + print("You've been succesfully registrated!") #?return или сразу переход на (3) case _: print("Invalid option. Try again.") diff --git a/Laba3/task_Lab3.py b/Laba3/task_Lab3.py index 8769f1f..919c0bf 100644 --- a/Laba3/task_Lab3.py +++ b/Laba3/task_Lab3.py @@ -2,6 +2,10 @@ def main(): - #TODO: some interface + AlphaBank = Bank("AlphaBank") + interface = BankInterface(AlphaBank) + + interface.MAIN_menu() pass +main() \ No newline at end of file From 3f6d14c59a34178d85165bc93157314eadd1fd75 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 11:14:41 +0300 Subject: [PATCH 13/18] Remove bank and client from paremetres of methods --- Laba3/__pycache__/classes.cpython-313.pyc | Bin 0 -> 7075 bytes Laba3/classes.py | 42 +++++++++++----------- 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 Laba3/__pycache__/classes.cpython-313.pyc diff --git a/Laba3/__pycache__/classes.cpython-313.pyc b/Laba3/__pycache__/classes.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..baade0bdd077705751dd64b7557e6b1ad14c1740 GIT binary patch literal 7075 zcmbtZO>7&-72aL`Eh$ozWRm)$q?PbarJW0i5V%nM~ctIS2qcqsE*W$s)c(ULL8$6wa?I7mWfgPCIpn`Q`?W{GQr zA?`FsJZV=CL%eAik@(UckbK%p{5fBO*W7PN%6q%m$1e7hG3JeV2J+lyDIqel+hDx~ascmmxk$3s!KGS5=&cAP6Lg1pz6WHTGKz)2(O}U<>sn z5U?4c_U+K|O6d4Hx6?bgIaKXEv+n*dcrW;Hy25wCwrunLU-12#gBAYxm#|rUkc6S3 z11&f%-KSR}^Q?V3#@v9}D%@+A^ zEaVkyd2Mugwvu*er}lw>^~HKVD*UCeK2Z<1KY0INoxOV=rt|o>UZyQd7XlmW2Sqw8 z-QrXtfFMFN0*C^lxKzxR3z!dz;%~}Q!Kev~;zFLNr9xhjm7*v%dLVF$42huV0-;4k zQ7uWOd`6T?C6b>nmt<8GA2D=%dRPS4Mg^Lc8VB(KQ*Uj%d%fP(z2%PXyWO79eh|bH z5cDi$r+mVx%$jQxY zEpi6R>e1Lvq^Udh250$$PMU3cvYdG$KZDt0lAzxl^R9KSX-h+R z7Oq@oALg&(nsEWH+!QBpSORlvB<-PJuv35<3laL5DD9}RjqWx3gg%0RrN+E`jhd+` z;L8sHPkd@Ea1HGgpfWD3olX@69V39F20nx$5i&ZWBn2V179UMo=&|8VkylL2kr!Z& zYbS0O%ct+i!n`aif?CdGWObojD69$=u;lC@IRmN*4>=1zWEh0zqwJf{k`XLAht+Ny z>ijx~ivaIYs8ih_z*Fh2ieUJnMV-Ji0F5K4zXL&Gx6{@8$+gY1)%dw;*U0*0J$&rL z_wT*`@#J>+R3&`saa-)0w&+&uVy*4c<5-0o*@OriH#>0tvkMMP0e?309 zgHqUz4_D&DpJi+Dv7Pwf*3gYFwfM!oCBqTREE55Jiy$dk*m;8aaRK-gH<-E;$Wt3`F?JI*92ATD zuJt%K(mFRFgv(HG1VKBo-mUm+)!2pg7VzmGhVO+xZuycwq5GthpqEPcNe_rhn-O2moA7C2JwCEL%{M-HSyWu%XZo+l(yE8_O5$gy3lq0`0}?aBCRV9ZF8LrF~Q%&JxB%cYG){9h0|@ z>7XZnqh{(;F!(@f?Y*O}?$$C8iIm9{%SuW2bOqfRnk8dNP|+QhDy-y7i#F|-lGo*u zAQcK`nJQo?CF4baI?A=)%X-%it}4QqayF?mTG-Uc;K14BE?VU-GLYs^7nkJHA~<86 z(R?;W>%dMFr~Dh>STY#$j;7!5(^K%9n2fm(<< zTBTUhy>QA7mgK&&m3-)y=HIPf~!V2H0zU5FGjqLh{6Nfv)cUfW%!vo98 z;0g~6f(b&sJmBA(TAMzK|F?_FLV4N5FSUSo0OVOBtq4m+MP7xXG4RcjqAq|}r$rbS z8n8-Im{TN^i!hcBRId%FAsAt1*}`Khnh^F57Z>PVYo$LTgoJbe-9b-4PmU0fT!j*C z=rHV#Vq3(PC>q$?8n{#KUa3ZZtH*%|xdy6CFhR*^B|Zw?)&`|Ui337?&xg)KKIn(FWZn|FEeSzUe+8PG~!4l_@-eBawG*c z!4))(P%wBSD6YYuiuZMhP~0(yOZG>?7@Z8E)WZ{0YaX89Gs@xcE<(G#oZIIqBrW zhfq(D%YM+BjtukWkzt$^{Ab571YRN_xNd2NS}iOsVVs0dr3QPO46MJQ>d`lDA;HBF z9J(pCXRrbV!b%lDz=Kk(^X@IUfZt8+dpXbGKF`9Vk{iSm6gtkaNpqZ!LyZ&X&wFFm zaSk$&=1EJ=p9m0OMrIeImY5et2e{SLgFpdC>!xeVr-pYEbKE6FKcf2zQyC(F=c{{pZR*R;r`7;6*xgFZ3|G z9UHE|KR!v{r3b#?2R275{E4slf#)0_?xT~Hj#%&&oKM7oUeXQu8+$w?Rz=!b{+cU^C7jMN~!itCK?kbGX3-S4GMwn%&RQ9H~vBNvfwn z07Hb^@7}0)_iVXi`) Date: Sun, 12 Oct 2025 11:16:24 +0300 Subject: [PATCH 14/18] add \n at the end of the strings --- Laba3/__pycache__/classes.cpython-313.pyc | Bin 7075 -> 7557 bytes Laba3/classes.py | 10 +++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Laba3/__pycache__/classes.cpython-313.pyc b/Laba3/__pycache__/classes.cpython-313.pyc index baade0bdd077705751dd64b7557e6b1ad14c1740..ae2c5b014fd5fc71cb11e3500c1101ec9d3ccd8a 100644 GIT binary patch delta 2217 zcmaJ@U2Kz87(Qofzpm@w*7d(%*D|-2rmhUx0QUn0wlQ1=akJUj)UI}2{Q`c&(?Y}> z;Q|o?#_)P0A^b=pVvNES@y;8$(u7LmYO@F$VS znSdr;(0|Q+#htf>3pUT9-BGZ)7Hn-fTifN?Ytj`dZ|j8TbsjZQx)qM=B5sO@*WmIs zZA^y=i4E&l%n8gpO{Vp5U)K+2qu|gex#Ix>WM9v?Rv85ed}?&TEtlO`P8HX@T<7-c zOYz5b<+;%bLPpQSxw?0^3+!q1U>zKk{B?7ZJR6s0StmDbKnT^U+3S-BrIehF?-^jv zpgB{E05kelApqvROL=iCJkUR&QMg+_ zOgDjO=%aP8-w=T>G@GoJT}tddayG^063Ntq0r*GLF~wRj^mWRd_!UwwLFp?u5C||M z+L;NV=vosX62}{rvhny3&SrE7$4J2;o;5HF_LGX_=mmZgs}#4sq`1{g{?h38Av*!C zI04tMX=4VsXY^4$oHF|Lz7;=HNtux{@hD!Ma%Js`c&ml7tc04e+Mr#qnDph8sYd@|6{>^M_KhEXiric7-~HAZRrA)w7LwPF1Y4=5ApRAAJm$%o~FPw?=M` zGgSG0@p&keRoD4Fqqsgz@UcIB&;RMHM^eOAWKWg9S7EPORDKbnm?l^NxGa=5uC1W( zBy=>)I(Oj&5E39wJi`$oc#L`qLNY@h-mef=&Ssg4khJ63;VYUXnYNf0mq0jmhgoS#LtVVho zj#&2%a&C&XgRwD{AZ;ZM7wt`rGdQS>uoprOzvKOqpL(Wg9PSMnfEsMT9KnuJKF#-HdpT6g z8-HX8<8TsgJ0f&a$;#{;qUSNIK{)T+MlZtm&M7(rU9L9zAxycxL@%#966P7ND#I}} z6r0pC9I4dEN04>TJ(0q0c<6Q;KjBfd2*=2MIBxI6jdpl?8$Lse!ho9DK{(^_`njA~ zh68`vY@P$(lfsuQJ; VhHA{zv_uddwcDv_nII?|{tM>I=bZom delta 1757 zcmZvcOKclu5XblPW7m%3IF8rvjpHOujFrYonx-YM<{g^0sUfaWX(+}xPB5gKuy%wH zIkbmVf#|0sgB$gt?o$r#3Z3w>iMQznE^}Pc!Er$@ z&dnL&hRNY!eT=q|ZHbHN)fEjK7Y8Ofb#VqGbzZBXvSv00ukrIPV^N=xb46oDUR}!- zg=}U?PGn@b&pUl#y+Vm7A(SGYOyx2wa#l|VfLZ9^8}Th0g#jVtE{N^>qVK@z+7~^0 zVq0Ep+gd1y9dKRnX}Pm{*byQ|OhZf7t1Bn+6h@&ZiODZ<^8&P*hMVBZ_e!5+Vi${ zsI57rFG#&GQ*+41px1Jioq%=A5UYVNEfLlZUm4m0im=3og`#ajjXfjh(#m2ol|G!p zkSVp%>;e_5s?Px`LAlS?|6s$2wMoFDpr1jPJ)lG053EfF8Vy)CdHhwYaViA0h!Pf& z%~_$xE=g6DGgT_L#Hp2w);ZZHkgofd3D99{f~alKeWx@PZp>FJi#8JP+xqxts4SbX zYwNids5u1?hz9>Mcko%dX&_)SH)jcW58l4ob`W z@={+xIt?$?x0G(dPe*S7&N$KIVD;DoV6mHpk_GNLM0i|Z3sJiu*i~jTykT#4TQE)a zi5V-%vl+N!UuYOXhth!(=1YSD#~Pk?Oru4c{a{e3r8ScvH-z{E*%R<#LoiZ-D>I>` zColEjL{t%#ERb+|by~l52S<^#i%m%Dj181u^^qQBCNKR zyY{aQDSbi{#<&tRDD>f3futW4lLN_8SqTJ*j8eGOv_ORQA z`d167wqXdi3|=s~&aw@7&Xwd}puJb%3s(nw7k+VFV&|aW9bmWMvU{-qD#c?cr4C-e z*P?GcDZf6Zl_GL&MNYq!$SFxVyO>sPQ!r{U?0Wrh-R-a+jc^_;o+j6O<#k$4_-963 z3*w4!$rI{4M{YVxIZyI`$Z>LzY{0fB!s05`AD(HpiBwat?mfdkg0H<-*i~@(+SnEh z`R?JWzkQJgBF^GJk}J>U91QzCcx#{cFFuj)1bpxJvTgX)KZv1PrNR2o=wxEla?gM) z`I}bgn>w#pNtQ|GNG3?uU|VX&%)XPRd9_z@a5c8DH=)0=(S4k?J>XCty~qaGD0{$> LJ{pB Date: Sun, 12 Oct 2025 11:24:00 +0300 Subject: [PATCH 15/18] Some changes --- Laba3/__pycache__/classes.cpython-313.pyc | Bin 7557 -> 7563 bytes Laba3/classes.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Laba3/__pycache__/classes.cpython-313.pyc b/Laba3/__pycache__/classes.cpython-313.pyc index ae2c5b014fd5fc71cb11e3500c1101ec9d3ccd8a..630dcb0eb0635adb05c9b4c40385406484e4e144 100644 GIT binary patch delta 1139 zcmZvbO>7fK6vuaBuf6u#vHbnDj@Jngty4Q61qrbEP?`jc5;xe6QsS!Ck}O~)EM=04 zrWevfD-a+mJ+Ioq+Z|%rJbPm6rc{B6g z|GjzpMd3=p`@-vWb8Jj#f1NpY$J@{Q?I%@zS?Qr@rn?wmoZn*)#jd&F2Tu~d;Z2f< z^Nt*G!?%uuWEVVhtT-!1ylRANFzalPez@(t?;Ec2`#<0~RpPigt|G#yUxJn}%1?9L z%ysxvDC|s)=4*6aR!^%<-7Syh-=mtkrpdZ?K`u?WsU71haMYD8XW3M7&>^(EgFsoP z^Hft`YBZPVFq-lVip^4Ox)xWOn!eU3P0&$hUbQjEvP?aAFb6-m(&Qri?i$Y=H8Le5 zb?mFDt%Uqrs&7lmJVnZzQtpYA`$Zatl6(K|S$6Gfu1?s;8db8VGuH{rt!LZb{Z@GR zTnNHF_sE#7tC)t^iB4rrv7=E}&uXjaVq0Gxg5r*WG_!1QPb104Qo)E6FNs@%=ep~% zYg3S(2-1!EuYv+KaZns%=V%U*hcCsESp2!*;rBl83-X7_f7u>BOMSSRf$!|ot%T=z z4_Seg-evZ9o4o@>ftS76A*;MXx4dTH+{c=(H}%tvroN`pQ|h8dqv&QBW_<-R0#|)C z?+kgtkwh68dB63y?>-?_xb3g>Z9g4e7)MzCogM#>4(yFuFE+yV-pKq2=z*g1QzO1^ zgg>CxVKVe?z3tJo%~dC;!fu(i@e^gsw`rT4tF!~~-2^PLrU$cVsEdo|KGE0O zP4ZUAN%%Qbbe=Hc3r4sO;qVeU1a(nXN~rq?ViM7Zz$a-})9RxlE{pIWJVc7Dx^WO9 z-#hAP{1ASOY>;W#7hNC?cp1&W-DuFRvMqQNPr^nt=x?yaDmGE4DQ7^8?eOD~c7z2s zD=Q+XVhC!nL52M_94#Ye5dWuV9yjLUW^9biqn_43v7Lm)k0kzJhF6Jv0L8sg@EROQ zUVKZ-6g*7Mv5N!JVX>=d8FVR`K94~t!i&%mHN+I+0^E|$IIP0VLnPHt)?r^N?a2Pi L4UsH-lp1^uXmI`D delta 1032 zcmZXSOH30{6o%)vOkdLnwDdiNf~|yNdB%iL&?@o>3TUBHe591NNCQsI6qUFU7bF^E zBpw$AEnSk}AYAzL6p$f|0g9T znh@c^sO8mS2|X_q?tKp!{+|Tha_A3 zZEjtozi+x@dc=Lv_(T&9=7%|}mutbW9?<}=cn3V?9A&O8jh=1Ys<5zO@;jhl{rOey znSx9~);I;n{u%>yvMZWhR|@9rm9!vagiG;^Fq0N163Mh^$JUK7YzmPkSTGG6 zPLgegxK1H${rOGP3Lz1AQx@^;7>?&V5psL=PJ8f~TkW#XP4wHI3-?0K+^)VRIj>9B z+5B5G5YhsD3}uP2}awJ>H;P&!aLg> zlsZ`Gw4W^-qp2LB*!g7!Vae_zWCjwo|=CLweeN} diff --git a/Laba3/classes.py b/Laba3/classes.py index 32417a9..c5a736b 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -22,7 +22,7 @@ def find_client(self, ID): class BankInterface: def __init__(self, bank): - self._bank = bank + self.bank = bank #// MAIN_menu вроде готово def MAIN_menu (self): #*def to create or sing in ID @@ -55,15 +55,15 @@ def sign_in(self): case 1: break #back to first cycle case 2: - self.registration(self.bank) + self.registration() print("You've been succesfully registrated!") #?return или сразу переход на (3) case _: print("Invalid option. Try again.") - def registration(bank): + def registration(self): client_name = input("Enter your name and surname: ") - bank.add_client(client_name) + self.bank.add_client(client_name) class ClientInterface: From 5758d45ba9c6ba67e3ab9c7e56f99473e7bf3fc4 Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 12:44:08 +0300 Subject: [PATCH 16/18] Add connections between Bank anf CLient Interface --- Laba3/classes.py | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index c5a736b..3ef1648 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -1,24 +1,21 @@ class Bank: - clients = {} - number_of_clients = 0 def __init__(self, name): self.clients = {} self.number_of_clients = 0 self.bank_name = name - pass def add_client(self, name): ID = self.number_of_clients #TODO реализоаать ID self.clients[ID] = Client(ID, name) self.number_of_clients += 1 - pass + return ID def find_client(self, ID): - for client in self.clients: - if ID in client: - return True - return False + return ID in self.clients + + def get_client(self, ID): + return self.clients[ID] class BankInterface: def __init__(self, bank): @@ -28,13 +25,13 @@ def __init__(self, bank): def MAIN_menu (self): #*def to create or sing in ID while True: - action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create ID\n")) + action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create new ID.\n")) match action: case 1: - self.sign_in(self.bank) #дальнейший ход интерфейса + self.sign_in() #дальнейший ход интерфейса return case 2: - self.registration(self.bank) #дальнейший ход интерфейса + self.registration() #дальнейший ход интерфейса return case _: print("Invalid option. Try again.") @@ -44,7 +41,8 @@ def sign_in(self): while True: client_ID = int(input("Enter ID: ")) #?потом string if self.bank.find_id(client_ID): - #дальнейший интерфейс + client_interface = ClientInterface(self.bank.get_client(client_ID)) #go to user interface + client_interface.MAIN_not_menu() return else: print("No valid ID. Try again or create an ID.") @@ -56,14 +54,17 @@ def sign_in(self): break #back to first cycle case 2: self.registration() - print("You've been succesfully registrated!") - #?return или сразу переход на (3) + return case _: print("Invalid option. Try again.") def registration(self): client_name = input("Enter your name and surname: ") - self.bank.add_client(client_name) + client_ID = self.bank.add_client(client_name) + print(f"You've been succesfully registrated! Your ID: {client_ID}") + client_interface = ClientInterface(self.bank.get_client(client_ID)) + client_interface.MAIN_not_menu() #go to user interface + class ClientInterface: @@ -77,7 +78,7 @@ def MAIN_not_menu(self): "\n 3.Operations with account.\n 4.Get all accounts statement\n")) match action: case 1: - self.openning_interface(self.client) + self.openning_interface() print("Account succesfully opened.") return case 2: @@ -85,7 +86,7 @@ def MAIN_not_menu(self): print("Account closed.") return case 3: - self.account_operations(self.client) + self.account_operations() return case 4: self.client.accounts_statement() @@ -130,16 +131,13 @@ def openning_interface(self): - - class BankAccount: - amount_of_money = 0 - account_number = 0 - def __init__(self, currency, owner_ID): self.currency = currency self.owner_ID = owner_ID + self.balance = 0 + self.account_number = 0 def TopUp_account(self): pass @@ -152,12 +150,12 @@ def withdraw_money(self): class Client: - accounts = {} - number_of_accounts = 0 def __init__(self, ID, name): self.ID = ID self.name = name + self.accounts = {} + self.number_of_accounts = 0 def get_ID(self): return self.ID From 491eee312dfbaf9f0ed3d166b643938c88520bcd Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Sun, 12 Oct 2025 13:14:49 +0300 Subject: [PATCH 17/18] Add methods to ClientInterface and create connection between Client and Account Interfaces --- Laba3/classes.py | 78 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/Laba3/classes.py b/Laba3/classes.py index 3ef1648..6b850dd 100644 --- a/Laba3/classes.py +++ b/Laba3/classes.py @@ -28,10 +28,10 @@ def MAIN_menu (self): #*def to create or sing in ID action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create new ID.\n")) match action: case 1: - self.sign_in() #дальнейший ход интерфейса + self.sign_in() #дальнейший ход интерфейса внутри return case 2: - self.registration() #дальнейший ход интерфейса + self.registration() #дальнейший ход интерфейса внутри return case _: print("Invalid option. Try again.") @@ -82,12 +82,18 @@ def MAIN_not_menu(self): print("Account succesfully opened.") return case 2: - self.client.close_account() + self.clossing_interface() print("Account closed.") return case 3: - self.account_operations() - return + while True: + acc_number = input("Enter account number: ") + if self.client.find_account(acc_number): + acc_interface = AccountInterface(acc_number) + acc_interface.account_operations() + return + else: + print("You don't have account with this number. Try again.") case 4: self.client.accounts_statement() print("Something") @@ -95,49 +101,76 @@ def MAIN_not_menu(self): case _: print("Invalid option. Try again.") - def account_operations(self): + def openning_interface(self): while True: - action = int(input("Choose action:\n 1.Top up account.\n 2.Withdraw money.\n 3.Transfer money to account.\n")) + action = int(input("Choose currency of account:\n 1.USD.\n 2.BYN.\n 3.EUR.\n")) match action: case 1: - self.client.TopUp_account() + print(f"Your account number {self.client.open_account("USD")}") return case 2: - self.client.withdraw_money() + print(f"Your account number {self.client.open_account("BYN")}") return case 3: - self.client.money_transfer() + print(f"Your account number {self.client.open_account("EUR")}") return case _: print("Invalid option. Try again.") - def openning_interface(self): + def clossing_interface(self): while True: + acc_number = input("Enter account number: ") #makedecorator + if self.client.find_account(acc_number): - action = int(input("Choose currency of account:\n 1.USD.\n 2.BYN.\n 3.EUR.\n")) + while True: + action = int(input("Are you sure you want close this account?\n" \ + "1.Yes\n 2.No\n")) + match action: + case 1: + self.client.close_account(acc_number) + return + case 2: + return + case _: + print("Invalid option. Try again.") + + else: + print("You don't have account with this number. Try again.") + + +class AccountInterface: + + def __init__(self, account): + self.account = account + + def account_operations(self): + while True: + + action = int(input("Choose action:\n 1.Top up account.\n 2.Withdraw money.\n 3.Transfer money to account.\n")) match action: case 1: - self.client.open_account("USD") + self.account.TopUp_account() return case 2: - self.client.open_account("BYN") + self.account.withdraw_money() return case 3: - self.client.open_account("EUR") + self.account.money_transfer() return case _: print("Invalid option. Try again.") + class BankAccount: - def __init__(self, currency, owner_ID): + def __init__(self, currency, owner_ID, account_number): self.currency = currency self.owner_ID = owner_ID self.balance = 0 - self.account_number = 0 + self.account_number = account_number def TopUp_account(self): pass @@ -160,13 +193,18 @@ def __init__(self, ID, name): def get_ID(self): return self.ID + def find_account(self, acc_number): + return acc_number in self.accounts + #? get_name def open_account(self, currency): - self.accounts[self.number_of_accounts] = BankAccount(currency, self.ID) + self.accounts[self.number_of_accounts] = BankAccount(currency, self.ID, self.number_of_accounts) self.number_of_accounts += 1 + return self.number_of_accounts - 1 - def close_account(self): - #delte from dict + def close_account(self, acc_number): + del self.accounts[acc_number] + print("Account succesfully deleted.") pass def account_statement(self): From 95b5af6317bcb4a4c287d82a254e8ea8b49c434a Mon Sep 17 00:00:00 2001 From: Andrusha-cpp Date: Mon, 13 Oct 2025 23:48:21 +0300 Subject: [PATCH 18/18] Finish project with a lot of work --- Laba3/classes.py | 212 ------------------------------- Laba3/task_Lab3.py | 277 ++++++++++++++++++++++++++++++++++++++++- statement_10000001.txt | 8 ++ 3 files changed, 284 insertions(+), 213 deletions(-) delete mode 100644 Laba3/classes.py create mode 100644 statement_10000001.txt diff --git a/Laba3/classes.py b/Laba3/classes.py deleted file mode 100644 index 6b850dd..0000000 --- a/Laba3/classes.py +++ /dev/null @@ -1,212 +0,0 @@ -class Bank: - - def __init__(self, name): - self.clients = {} - self.number_of_clients = 0 - self.bank_name = name - - def add_client(self, name): - ID = self.number_of_clients #TODO реализоаать ID - self.clients[ID] = Client(ID, name) - self.number_of_clients += 1 - return ID - - def find_client(self, ID): - return ID in self.clients - - def get_client(self, ID): - return self.clients[ID] - -class BankInterface: - def __init__(self, bank): - self.bank = bank - - #// MAIN_menu вроде готово - def MAIN_menu (self): #*def to create or sing in ID - while True: - - action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create new ID.\n")) - match action: - case 1: - self.sign_in() #дальнейший ход интерфейса внутри - return - case 2: - self.registration() #дальнейший ход интерфейса внутри - return - case _: - print("Invalid option. Try again.") - - #//тут вроде тоже всё - def sign_in(self): - while True: - client_ID = int(input("Enter ID: ")) #?потом string - if self.bank.find_id(client_ID): - client_interface = ClientInterface(self.bank.get_client(client_ID)) #go to user interface - client_interface.MAIN_not_menu() - return - else: - print("No valid ID. Try again or create an ID.") - - while True: - action = int(input("1.Try again\n 2.Create new ID\n")) - match action: - case 1: - break #back to first cycle - case 2: - self.registration() - return - case _: - print("Invalid option. Try again.") - - def registration(self): - client_name = input("Enter your name and surname: ") - client_ID = self.bank.add_client(client_name) - print(f"You've been succesfully registrated! Your ID: {client_ID}") - client_interface = ClientInterface(self.bank.get_client(client_ID)) - client_interface.MAIN_not_menu() #go to user interface - - -class ClientInterface: - - def __init__(self, client): - self.client = client - - def MAIN_not_menu(self): - while True: - - action = int(input("Choose action:\n 1.Open account.\n 2.Close account." \ - "\n 3.Operations with account.\n 4.Get all accounts statement\n")) - match action: - case 1: - self.openning_interface() - print("Account succesfully opened.") - return - case 2: - self.clossing_interface() - print("Account closed.") - return - case 3: - while True: - acc_number = input("Enter account number: ") - if self.client.find_account(acc_number): - acc_interface = AccountInterface(acc_number) - acc_interface.account_operations() - return - else: - print("You don't have account with this number. Try again.") - case 4: - self.client.accounts_statement() - print("Something") - return - case _: - print("Invalid option. Try again.") - - def openning_interface(self): - while True: - - action = int(input("Choose currency of account:\n 1.USD.\n 2.BYN.\n 3.EUR.\n")) - match action: - case 1: - print(f"Your account number {self.client.open_account("USD")}") - return - case 2: - print(f"Your account number {self.client.open_account("BYN")}") - return - case 3: - print(f"Your account number {self.client.open_account("EUR")}") - return - case _: - print("Invalid option. Try again.") - - def clossing_interface(self): - while True: - acc_number = input("Enter account number: ") #makedecorator - if self.client.find_account(acc_number): - - while True: - action = int(input("Are you sure you want close this account?\n" \ - "1.Yes\n 2.No\n")) - match action: - case 1: - self.client.close_account(acc_number) - return - case 2: - return - case _: - print("Invalid option. Try again.") - - else: - print("You don't have account with this number. Try again.") - - -class AccountInterface: - - def __init__(self, account): - self.account = account - - def account_operations(self): - while True: - - action = int(input("Choose action:\n 1.Top up account.\n 2.Withdraw money.\n 3.Transfer money to account.\n")) - match action: - case 1: - self.account.TopUp_account() - return - case 2: - self.account.withdraw_money() - return - case 3: - self.account.money_transfer() - return - case _: - print("Invalid option. Try again.") - - - - -class BankAccount: - - def __init__(self, currency, owner_ID, account_number): - self.currency = currency - self.owner_ID = owner_ID - self.balance = 0 - self.account_number = account_number - - def TopUp_account(self): - pass - def money_transfer(self): - pass - def withdraw_money(self): - pass - - - - -class Client: - - def __init__(self, ID, name): - self.ID = ID - self.name = name - self.accounts = {} - self.number_of_accounts = 0 - - def get_ID(self): - return self.ID - - def find_account(self, acc_number): - return acc_number in self.accounts - - #? get_name - def open_account(self, currency): - self.accounts[self.number_of_accounts] = BankAccount(currency, self.ID, self.number_of_accounts) - self.number_of_accounts += 1 - return self.number_of_accounts - 1 - - def close_account(self, acc_number): - del self.accounts[acc_number] - print("Account succesfully deleted.") - pass - - def account_statement(self): - pass - \ No newline at end of file diff --git a/Laba3/task_Lab3.py b/Laba3/task_Lab3.py index 919c0bf..6ca9f78 100644 --- a/Laba3/task_Lab3.py +++ b/Laba3/task_Lab3.py @@ -1,4 +1,279 @@ -from classes import Bank, BankAccount, Client, BankInterface, ClientInterface +class Bank: + + def __init__(self, name): + self.clients = {} + self.number_of_clients = 0 + self.bank_name = name + + def add_client(self, name): + ID = 10000000 + self.number_of_clients + 1 + self.clients[ID] = Client(ID, name) + self.number_of_clients += 1 + return ID + + def find_client(self, ID): + return ID in self.clients + + def get_client(self, ID): + return self.clients[ID] + +class Client: + + def __init__(self, ID, name): + self.ID = ID + self.name = name + self.accounts = {} + self.number_of_accounts = 0 + + def get_account(self, acc_number): + return self.accounts.get(acc_number) + + def get_ID(self): + return self.ID + + def find_account(self, acc_number): + return acc_number in self.accounts + + def open_account(self, currency): + account_number = f"{self.number_of_accounts + 1:02d}C{self.ID}" #number 00C00000000 + self.accounts[account_number] = BankAccount(currency, self.ID, account_number) + self.number_of_accounts += 1 + return account_number + + def close_account(self, acc_number): + del self.accounts[acc_number] + print("Account succesfully deleted.") + pass + + def account_statement(self): + if not self.accounts: + print("You have no открытых счетов.") + return + + with open(f"statement_{self.ID}.txt", "a") as f: # просто добавление в файл + f.write(f"\nAccount Statement for {self.name} (ID: {self.ID})\n") + for acc in self.accounts.values(): + f.write(f"{acc.account_number}: {acc.currency}, balance = {acc.balance}\n") + + print(f"Statement updated in 'statement_{self.ID}.txt'") + +class BankAccount: + + def __init__(self, currency, owner_ID, account_number): + self.currency = currency + self.owner_ID = owner_ID + self.balance = 0 + self.account_number = account_number + + def TopUp_account(self, add_balance): + self.balance += add_balance + + def money_transfer(self, acc_recipient, add_balance): + self.withdraw_money(add_balance) + acc_recipient.TopUp_account(add_balance) + print(f"Transferred {add_balance} {self.currency} to account {acc_recipient.account_number}.") + + def withdraw_money(self, take_balance): + self.balance -= take_balance + pass + + def get_balance(self): + return self.balance + +class BankInterface: + def __init__(self, bank): + self.bank = bank + + def MAIN_menu (self): #*def to create or sing in ID + while True: + + action = int(input("Choose action:\n 1.Sing in to ID.\n 2.Create new ID.\n 3.Exit menu.\n")) + match action: + case 1: + self.sign_in() #дальнейший ход интерфейса внутри + return + case 2: + self.registration() #дальнейший ход интерфейса внутри + return + case 3: + return + case _: + print("Invalid option. Try again.") + + def sign_in(self): + while True: + client_ID = int(input("Enter ID: ")) + + if self.bank.find_client(client_ID): + client_interface = ClientInterface(self.bank.get_client(client_ID)) #go to user interface + client_interface.MAIN_not_menu() + return + else: + print("No valid ID. Try again or create an ID.") + + while True: + action = int(input("1.Try again\n 2.Create new ID\n")) + match action: + case 1: + break #back to first cycle + case 2: + self.registration() + return + case _: + print("Invalid option. Try again.") + + def registration(self): + client_name = input("Enter your name and surname: ") + + client_ID = self.bank.add_client(client_name) + print(f"You've been succesfully registrated! Your ID: {client_ID}") + client_interface = ClientInterface(self.bank.get_client(client_ID)) + client_interface.MAIN_not_menu() #go to user interface + + +class ClientInterface: + + def __init__(self, client): + self.client = client + + def MAIN_not_menu(self): + while True: + + action = int(input("Choose action:\n 1.Open account.\n 2.Close account." \ + "\n 3.Operations with account.\n 4.Get all accounts statement\n 5.Exit menu.\n")) + match action: + case 1: + self.openning_interface() + print("Account succesfully opened.") + case 2: + self.clossing_interface() + print("Account closed.") + case 3: + self.operations_interface() + case 4: + self.client.account_statement() + case 5: + return + case _: + print("Invalid option. Try again.") + + def openning_interface(self): + while True: + + action = int(input("Choose currency of account:\n 1.USD.\n 2.BYN.\n 3.EUR.\n")) + match action: + case 1: + print(f"Your account number {self.client.open_account("USD")}") + return + case 2: + print(f"Your account number {self.client.open_account("BYN")}") + return + case 3: + print(f"Your account number {self.client.open_account("EUR")}") + return + case _: + print("Invalid option. Try again.") + + def clossing_interface(self): + while True: + acc_number = input("Enter account number: ") #makedecorator + if self.client.find_account(acc_number): + + while True: + action = int(input("Are you sure you want close this account?\n" \ + "1.Yes\n 2.No\n")) + match action: + case 1: + self.client.close_account(acc_number) + return + case 2: + return + case _: + print("Invalid option. Try again.") + + else: + print("You don't have account with this number. Try again.") + + def operations_interface(self): + acc_number = input("Enter account number: ").strip() + if not self.client.find_account(acc_number): + print("No such account.") + return + + account = self.client.get_account(acc_number) + acc_interface = AccountInterface(account, self.client) + acc_interface.account_operations() + +class AccountInterface: + + def __init__(self, account, client): + self.account = account + self.client = client + + def account_operations(self): + while True: + + action = int(input("Choose action:\n 1.Top up account.\n 2.Withdraw money.\n 3.Transfer money to account.\n 4.Exit.")) + match action: + case 1: + self.TopUp() + case 2: + self.withdraw() + case 3: + self.transfer() + case 4: + return + case _: + print("Invalid option. Try again.") + + + def TopUp(self): + try: + amount = float(input("Enter amount to top up: ")) + if amount <= 0: + print("Amount must be positive.") + return + self.account.TopUp_account(amount) + print(f"Account topped up. New balance: {self.account.balance}") + except ValueError: + print("Invalid input.") + + + def withdraw(self): + try: + amount = float(input("Enter amount to withdraw: ")) + if amount <= 0: + print("Amount must be positive.") + return + if self.account.balance >= amount: + self.account.withdraw_money(amount) + print(f"Withdraw successful. New balance: {self.account.balance}") + else: + print("Not enough money.") + except ValueError: + print("Invalid input.") + + + def transfer(self): + while True: + acc2_number = input("Enter number of account recipient: ") + if self.client.find_account(acc2_number): + recipient_account = self.client.get_account(acc2_number) # get account + while True: + try: + add_balance = float(input("Enter amount of money to transfer: ")) + if add_balance <= 0: + print("Amount must be positive.") + continue + if self.account.balance < add_balance: + print("Not enough funds for transfer.") + continue + self.account.money_transfer(recipient_account, add_balance) + return + except ValueError: + print("Invalid input.") + else: + print("You don't have account with this number. Try again.") def main(): diff --git a/statement_10000001.txt b/statement_10000001.txt new file mode 100644 index 0000000..63a3191 --- /dev/null +++ b/statement_10000001.txt @@ -0,0 +1,8 @@ + +Account Statement for grghrh (ID: 10000001) +01C10000001: USD, balance = 7000.0 +02C10000001: BYN, balance = 3000.0 + +Account Statement for grghrh (ID: 10000001) +01C10000001: USD, balance = 7000.0 +02C10000001: BYN, balance = 3000.0