From 0dacaf122aa2f8d593124819f06ddffd53b98ff8 Mon Sep 17 00:00:00 2001 From: muhammed Date: Mon, 25 Oct 2021 13:12:01 +0200 Subject: [PATCH] week_6 --- __pycache__/bank.cpython-39.pyc | Bin 0 -> 1322 bytes __pycache__/client.cpython-39.pyc | Bin 0 -> 1805 bytes bank.py | 20 +++++ client.py | 33 ++++++++ main.py | 131 ++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 __pycache__/bank.cpython-39.pyc create mode 100644 __pycache__/client.cpython-39.pyc create mode 100644 bank.py create mode 100644 client.py create mode 100644 main.py diff --git a/__pycache__/bank.cpython-39.pyc b/__pycache__/bank.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a8f30d672fc59540d09c80c4769ee8a12266fe65 GIT binary patch literal 1322 zcmZWp!EO^V5Vbd(O$bdvAR+aDaO{B}+AAl1ffF;{ge1k19ec)}c{A^Ac)eaDFkbys{Gvq2FFdRdu#p3pdJh&s zIz&+6By{9-97^60Q4;PI5$>haDT(q4@jd>H64Ge&csgv2r;SFf)?}Zv3A>1sgbnz) zWKqJkX5mY?5w_UrAl3|Tuic1KZFm|OW%11I}JQa)QD^HZfGBrA6Nvuta zy-i~i^CX!vgOSl#MD9r@M`JT>0U(>Sz_G$Ll4g(z7IGniB524Kwu?a=4HzGfWhyiT z#v(8)Gnvf*ArAo>6lRu*Z$=OK1m2}4j<|`l^hRjIhZ1_SsxstJluc3-q?1ukDkxpE zF;~z9BbBy|SPKYmSD=0aQ^cpacVsa}cw8S291dXWN3clJp+Kwig#dv-?G@>`1*x5~ zC<_nHo~Qt^)!aqKB7D6ZxW{<}Q=^XNbWQ@0$qBipZGhlnLDx?1YMJy^8E#w?RfV5F zt!TgdQ9~)+<9FR7RK(Nf`za8RHjgtgNo4brl*4D;g^u!S5X8W25ZuCC76hHu5m9UD z`41Xu*Fw7sn>jfn-|3wGpwt3XE*O0$uPpSFdj-A91G~joESN8^tu%2P&ddCFZ2pxm z!i>v-`+o?Yz`>9+YMi-qNq68Y+JR;b9kpjl0xW>3bV6Y7+C6+p*hJrJ+osJPu5k_G zVIXWhi6W`{lO)+aojpF>5Etw7IFVwP)jmkBvvi-efd`gmhV?;IqV?K$74|T%EM%6K zv{89^tm4%8B~<~R&75y<>hNY`wl{&*;hhx%p$}-4x=xkO?iWqk0NC~`$SA5K2=ZDG zj4bD{-wJ}S6P^?vh0RtdEQOKPJzP*eYYXzDu+NBDqZ9Jds#A5Wwe7okB?v?oL2$3& c+Lms;YjJE?OLp~nf#wDLkr9nDam!ouFI#g~lmGw# literal 0 HcmV?d00001 diff --git a/__pycache__/client.cpython-39.pyc b/__pycache__/client.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..641b21cd0dfca3bf6ce39a9e5808e77fc84cdf1f GIT binary patch literal 1805 zcmb7F-HsbI6t*Wbli754yDYs!Lhco0)kM8$3#zKB)v6$V8X*;gh*p|7W2bRE6(xEWK&v%aOC5ki3P+367|4}RDDkC2c* zaj;oBFt`WRybnf@F%eXFDIL>KiRcLbIT8MuH}-`0i1Y*g1103(AW4iD{ z*d*f%iLK2oPh-A7_k?k4wVD=I8rW_U$0}1cjwfs(?K~HCG&rYts!BXv8p)n=t@t#R z<{DGBUSs*OY|daj6K@=2*a_EsVVu*&371okGsc;Q_4$I`WI{cL?Nnx&&DlS10O5Vf zjZK#|0yQ`r7d};XE;K*ID++m%8-=&SNTxjHSt8pznPKlQAc%|-w423)!9A$vIv7dD z6iD!uih!Do1=!yv1uGj)fdsSFdm7oyXf_)$AAyo4@m=#@-n5;ao z)Ox?Vy??`zZv)X;kthBO5X#HW8Kne9Sg8np_H6j1Ya{fZ(K{e7I58Zly$=Xczx+f= zdFy`7I7_tTRtjc{B$39>ob*w=Sg-~g2A$HW6(EERM`fdQ{(0LI7(c|l%!EhCSBAE?McFe;nI$DxKYj_3L^fX?_Pr3hDW{TNNCHPRVS&<3z z%5$vf2rdHsOVEtNI-wo3wb_B`Dr%#67e)qgC$tBE?ZGef)}Xbk{vEU%@MR0tNB;w= zzCS82Z6fsH1wvd1&?)5l+prnx%W$OLL-P(A41VKg-6qN3gK2|Ekmg$DZli=|K>`o$ zx?ms0;L;IywD3wJv5rn}RNnYcMxLRZhnuPLW1l)Mpg}I)h_vMse8#Dgu48Omqke?y z#w?8Esu#x#mjTe6<*++w<>MLk2z;Qj~-X$Xf<1!_pK8?1bC<@#> hq-8gbMV`d5hX1m9@!NK(qC0ggcM&>+N#utS{Tl?o(60ah literal 0 HcmV?d00001 diff --git a/bank.py b/bank.py new file mode 100644 index 0000000..cf78b30 --- /dev/null +++ b/bank.py @@ -0,0 +1,20 @@ +'''**bank.py** + +- You will have class `Bank`. This bank will have instance variable `name` and class variable `clients` list. Initially this list will be empty. +- This class will have method `add_client` method which appends the client to list +- And lastly this class will have `authentication` method which takes `name` and `account_number` as parameters and authenticates the client''' +from client import Client +class Bank: + clients = [] + def __init__(self, name): + self.name = name + def add_client(self, name): + self.clients.append(name) + def authentication(self, name, account_number): + if Client.account[str(account_number)]["name"] == name : + print("authentication is succesfull!") + return True + else : + print("Authentication failed! \nReason: Name not found.") + return False + diff --git a/client.py b/client.py new file mode 100644 index 0000000..c17e7ac --- /dev/null +++ b/client.py @@ -0,0 +1,33 @@ +'''**client.py** +- You will have class `Client` inside this file. +- Class `Client` will have `account_number`, `name`, `total_amount` attributes +- `__init__` method will initialize these variables, it will take `name` and `total_amount` as params and will assign a random 5 digit int to `account_number` +- Lastly this class will have `withdraw`, `deposit` and `balance` methods. +''' +import random +class Client: + account={} + def __init__(self, name, total_amount): + self.name=name + self.total_amount=total_amount + self.account_number = random.randint(10000,99999) + print(f"Account created successfully! Your account number is: {self.account_number} ") + Client.account[str(self.account_number)] = {"name" : self.name , "total_amount" : self.total_amount} + '''def newaccount(self): + Client.account.update({str(self.account_number) : {"total_amount" : self.total_amount}}) + print(f"Succesfull . Your new balance : {self.total_amount} ")''' + def withdraw(self, amount): + if self.total_amount > amount : + self.total_amount -= amount + print(f"\nThe sum of {amount} has been withdrawn from your account balance") + print(f"Your current account balance is: {self.total_amount}") + return self.total_amount + else: + return "Insufficient funds" + def deposit(self, amount): + self.total_amount+= amount + print(f"The sum of {amount} has been added to your account balance.") + print(f"Your current account balance is: {self.total_amount}") + return self.total_amount + def balance(self): + print ("Your current account balance is: {self.total_amount}") \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..3fbe34e --- /dev/null +++ b/main.py @@ -0,0 +1,131 @@ +'''**main.py** +- This class initially will create a bank object with a name you choose and then will print the following menu (it should print this menu, until user says exit) [**hint:** use while loop]: +``` +Welcome to International Bank! + +Choose an option: + + 1. Open new bank account + 2. Open existing bank account + 3. Exit +``` +Then it will take the user input: +- If it is 1, create an account +First ask the name and then the deposit amount to user: +``` +To create an account, please fill in the information below. +Name: +Deposit amount: +``` +After this, it creates the account and prints the menu again +``` +Account created successfully! Your account number is: 88194 + +Choose an option: + + 1. Open new bank account + 2. Open existing bank account + 3. Exit +``` +- If it is 2, asks following info +``` +To access your account, please enter your credentials below. +Name: +Account Number: +``` +First asks name and then account number. +If credentials are wrong, print following, and then print the menu again: +``` +Authentication failed! +Reason: account not found. +``` +If credentials are correct, prints the following menu: +``` +Authentication successful! + +Welcome irem! + +Choose an option: + + 1. Withdraw + 2. Deposit + 3. Balance + 4. Exit +``` +And according to user input you can withdraw, deposit money. Or see the current balance. +If input is 1, asks for withdraw amount: +``` +Withdraw amount: +``` +And according to user input witdraws the amout and prints the menu again. +``` +The sum of 100 has been withdrawn from your account balance. + +Your current account balance is: 900 +``` +If input is 2, asks for deposit amount: +``` +Deposit amount: +``` +And according to user input, in this case 300. Prints following: +``` + +The sum of 300 has been added to your account balance. + +Your current account balance is: 1200 +``` + +If input is 3, shows the current balance: + +``` +Your current account balance is: 1200 + +``` +If input is 4, it goes back to other menu. + +- And lastly, in the main menu, if user input is 3: close the program''' + +from client import Client +from bank import Bank + +international_bank = Bank("International") +while True: + choice = input("Welcome to International Bank!\nChoose an option:\n1. Open new bank accountn\n2. Open existing bank accountn\n3. Exit") + if (choice == "1"): + print("To create an account, please fill in the information below.\nName\nDeposit amount:") + name =input("Name:") + total_amount=int(input("Deposit amount:")) + client = Client(name, total_amount) + international_bank.add_client(client) + elif (choice == "2"): + print("To access your account, please enter your credentials below.") + name =input("Name:") + account_number = int(input("Account Number:")) + '''if not international_bank.authentication(name, account_number=): + print("Authentication failed!\nReason: account not found.")''' + if international_bank.authentication(name, account_number) : + print("Authentication successful!\nWelcome {name}!") + choice1 = input("Choose an option:\n1. Withdraw\n2. Deposit\n3. Balance\n4. Exit") + if choice1 == "1": + withdraw = int(input("Withdraw amount:")) + for i in Bank.clients: + if i.name == name and i.account_number == account_number : + i.withdraw(withdraw) + elif choice1=="2": + Deposit_amount:int(input("Deposit amount:")) + for i in Bank.clients: + if i.name == name and i.account_number == account_number : + i.deposit(Deposit_amount) + print("The sum of {Deposit_amount} has been added to your account balance\nYour current account balance is: {Deposit_amount} + {balance}") + elif choice1=="3": + for i in Bank.clients: + if i.name == name and i.account_number == account_number : + print(i.balance()) + elif choice1=="4": + break + else : + print("Error") + elif choice == "3" : + break + else: + print("error")