From d191671b4f6f02cfd686fb9d562a3f66755cfecb Mon Sep 17 00:00:00 2001 From: VaNiesha Honani Date: Sun, 16 Nov 2025 22:06:54 -0800 Subject: [PATCH 1/3] updated guessing_game and first ver. of atm - more later --- __pycache__/game_engine.cpython-314.pyc | Bin 0 -> 1670 bytes atm.py | 127 ++++++++++++++++++++++++ game_engine.py | 24 +++++ guessing_game.py | 11 +- 4 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 __pycache__/game_engine.cpython-314.pyc create mode 100644 atm.py create mode 100644 game_engine.py diff --git a/__pycache__/game_engine.cpython-314.pyc b/__pycache__/game_engine.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cbc71ec7adaa53b2f530fadeecd6dc446c22958d GIT binary patch literal 1670 zcmZ`(L1-IS5dFK_l{U6y%XTC~q~djxh>8#iN)9=sC2o?2lHgd2tF%S+XDzLz1!-6P z|EtC#2H)y{X`mF^p6Y9FIhLN%Q*%^^AyR8f^H)+G;|yqa{`{HwGxKJ2 zX(BO3fLec?bDye&{ELSnX#=7EJ_uW6g;>gGM35AjCzd)(tjHDcKoW|joF{qh6&@C= z$cLm1g#J|!Y>4tTS`(qJL_{P_e26(qgog2iZbg7cEe&|g(uGkb;*1rA$gv=PyW?=~ zdiC3O%c&0Dm9a6)2q8xQ3lO%*{iG+=$SNbdCA2z0^JGOSE5jPf#DgdySqhv+9+nCj zL|$PfpDyP0AmVjeL6q5E&2I%U{JNe9qPEA^9TvnW_nY53wY(Z=+-a_{82E8aB$o@W z6+h<=<3-PPc*AZKtA5R)?WQe!-z)ll`*M9y<>fk*Swu!1ukLzIp}i3pl)9cPC=F7_ zyHOabb$rPLwng@5(mTdMI{TCNgST7S<)1ytrWhN~0kZ3g(Wag+__@HRZ-$_Sfs4P5la=&)sCSn7o?lM=eNTKGqY)PVaj^Ut}Z*fm{-^| z1k6WdXV_VggIEie+O9hs-_PZ8vN;TffSefdVPElzXMk;y10&H(=61Wg&Bqsik3HV# zO)TsgpS(2UVMU{?!5C#((K+dP`ozM#D3~My03U>pqhpv<5DkYWn0X7bP&tdX=m3~a z&OCbX@IlYW$TXl@j3*~W{u3uvW9a=G3H5TmjcZ|D dAG3>akB@N#|1hE`%HJgMT1zR}J^?0u{sWbbX)FK$ literal 0 HcmV?d00001 diff --git a/atm.py b/atm.py new file mode 100644 index 0000000..c26cb91 --- /dev/null +++ b/atm.py @@ -0,0 +1,127 @@ +#Version 1.0 +#Missing log out, log in to check account and creating a user account +#Extra stuff - storing accounts created so that I can keep making accounts +#And logging back into them. Version 1.5+ + +import sys +class Atm: + """Class representing ATM functions and bank transactions""" + def __init__(self): + self.user = "Vee" + self.pin = 1234 + self.balance = 10000 + self.deposit = 2000 + self.withdraw = 100 + self.card_inserted = True + self.logout = False + + def __str__(self): #interface screen + return( + "Transaction Receipt:\n" + f"Account User: {self.user}\n" + f"Balance: $ {self.balance}" + ) + + def is_card_inserted(self,atm_answer): + """definition to check if atm card is inserted + return True or False + """ + if atm_answer == "y": + return True + else: + + return False + + def auth_pin(self, pin): + """definition to validate pin entered against pin stored for user""" + if pin == self.pin: + return True + else: + return False + + def bank_options(self, option): + """definition to handle user option from bank interace""" + if option not in ('1', '2','3','x'): + print("Invalid option.") + option = input("Select an option: ") + + if option == '1': + self.check_balance() + if option == '2': + self.withdraw_money() + if option == '3': + self.deposit_money() + if option == 'x': + self.account_logout() + + def check_balance(self): + """definition to check balance""" + print(f"Current Balance: ${self.balance}\n") + self.user_interface() + + def withdraw_money(self): + """definition to withdraw money and return new balance""" + withdrawal_amount = int(input("Enter witdrawal amount (USD): ")) + if withdrawal_amount > self.balance: + print("Sorry, we cannot process the withdrawal.\n") + print(f"Current Balance: {self.balance}\n") + self.user_interface() + + else: + print(f"Processing withdrawal of ${withdrawal_amount}...") + print("Completed.") + new_balance = self.balance - withdrawal_amount + self.balance = new_balance + print(f"Current Balance : ${self.balance}\n") + self.user_interface() + + def deposit_money(self): + """defintion to handle deposits of money and return new balance""" + deposit_amount = int(input("Enter deposit amount: $ ")) + new_balance = self.balance + deposit_amount + self.balance = new_balance + print(f"Your new balance is: ${self.balance}\n") + self.user_interface() + + def user_interface(self): + """definition of user interface the mani definition for user interaction""" + print(""" + 1 - Check Balance\n + 2 - Make a Withdrawal\n + 3 - Deposit Money\n + X - Exit\n + """) + option = input("Select an option: ") + self.bank_options(option) + + def account_logout(self): + """defintion to handle account log out""" + return f"Exiting account...\n \n{str(self)}" + + +vees_atm = Atm() +print(" === Welcome to Bank of Vee ===\n") +AUTH_PIN = False + +debit_card_check = input("Did you insert debit card? (Y/N): ") + +CHECK_CARD = vees_atm.is_card_inserted(debit_card_check) +if CHECK_CARD is True: + bank_pin = int(input("Enter pin: ")) + AUTH_PIN = vees_atm.auth_pin(bank_pin) +else: + print("Sorry, you need to insert a debit card for ATM transacitons. Good Bye.") + sys.exit(0) + +if AUTH_PIN is True: + print(f"Welcome to Bank of Vee, {vees_atm.user}!\n") + vees_atm.user_interface() +else: + print("Sorry, this pin is not recognized. Have a Nice Day!") + sys.exit(0) +print(vees_atm.account_logout()) + + + + + diff --git a/game_engine.py b/game_engine.py new file mode 100644 index 0000000..a1fe0ed --- /dev/null +++ b/game_engine.py @@ -0,0 +1,24 @@ +import random + +class GuessingGame: + + def __init__(self, num): + self.num = num + self.answer = random.randint(1,num) + self._solved = False + + + def guess(self, user_guess): + if user_guess == self.answer: + print(f"Congratulations! You solved it. The answer was {self.answer}") + self._solved = True + + return self.response(user_guess, "Too high. Try again..") if user_guess >self.answer else self.response(user_guess, "Too Low Try Again") + + + def response(self, user_guess, message): + print(f"Oops! Your last guess {user_guess} was {message}") + pass + + def solved(self): + return self._solved \ No newline at end of file diff --git a/guessing_game.py b/guessing_game.py index e8f8965..29511d8 100644 --- a/guessing_game.py +++ b/guessing_game.py @@ -1 +1,10 @@ -class GuessingGame(): +import game_engine + +game = game_engine.GuessingGame(10) #1-10 +player_name = (input("Enter your name: ")) +print(f"Greetings {player_name}!") + + +while game.solved() is not True: + user_guess = int(input(f"Guess the number from 1 to {game.num}: ")) + game.guess(user_guess) \ No newline at end of file From 74d005a16b4fd6f78a30cbca8d1b2f59eb151418 Mon Sep 17 00:00:00 2001 From: VaNiesha Honani Date: Mon, 24 Nov 2025 16:28:31 -0800 Subject: [PATCH 2/3] guessing game and seperate Class --- __pycache__/game_engine.cpython-314.pyc | Bin 1670 -> 2036 bytes game_engine.py | 25 +++++++++++++++--------- guessing_game.py | 3 ++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/__pycache__/game_engine.cpython-314.pyc b/__pycache__/game_engine.cpython-314.pyc index cbc71ec7adaa53b2f530fadeecd6dc446c22958d..333acbbfff3ae7a047211839314a29576dacbca7 100644 GIT binary patch literal 2036 zcmah~O>7%g5PrM%+FN^*rb+BT<0u>2nwrvBLOoQ}ML;5|wlp+LF(8FJE%wGz|&&<5}X1+JR zG(40bF#gy-Z|_A2`3o2Q5$#R7S(vO7g9x%r4C$sMq!gJUhCD%x$Q3!%60#wkBe`gE z{AR80F`+ZlEqgV+=9L?cwNUCi#jn&`bPF&s!S!cENZ?*xj)+K_cyNh`qI;nj5s)z> z3NmgeAXOtKP8Eqr7;(5x^|c!fi*wtp+%RiabF9D8ajDNaCg-JIgu$hV32>_26_~7( zk4M~K8^zKq7_kH)MA}Nh1bCiZ`b#me7OB=`Io+2&CI?y&?3P zC8}PznV<9A3Nu9m7-4%ZpV2?{8hS`8-4?U@y((HE-SkzH>&^HaQteIsUUM8Mq*v`q z6_nVTZdOd&ooSBYuH&s9-dxBj4D;kGbq4%pNtiS2BfiQkUWaR~oXj-bNHl=0G~i^9 z!3+`lO0eaR9${gyhtBvKh;{O3GWBS3XR@6<|4cj68lQVI|I6*4Z$G)-8eME_2JAh& zu|5Cj*3PZ%LTmJ5Tg!DOr#I#|-$%RTPO_am*U?6{?mW1&{aPzqXlvI`Jh;}@3LRD3 zN_?GoxcJTRR)USd?WF-RVSx`2)>`*s5Z6+_fkC4xN*Z*+q71Z)9?;Z?1if&|=%qvV zR&?k^LJuJJi_ztr@iH9omq4tOzty4ENOrfm>pZ^jQ~dE-Yxtet)OSO)14N*S^8oGHzziM*e2)*n zCp9m881$Xe+4S)xy z$F}Z2xZhGIgJ5&fz+XVYkb794g^;gg##_o z_24*8Y1u1L%7(!UOQFDgvPlqric-KL>=HGFVD{$?VR5iILum>BTgrAxlq|=gG$;8( zhc>|salRea2aCl};E%ro;@__T*VE|Kb2+L^Jl8Z38CjW=_ElNQ>=6(F)W8S`FoO=_ sDA2=?Bs>gWl3ECXzQwX|gqL!}uosae=_xt;I~m%SGg78YKm=z00W<%*aW+>AGl#=n4*St1EoJ$U6-TN6yY_-5Op7bn@b^S*uG_h!F0KfTZ0o+}=A zC*WH8cs{>JE1v$y1J-a`W8UFTOp};FE_G_ODi*Vg^QO$+kpc;_b2LO>sceD{h)QD**kc;#2?7j43Wb_W zha|8c^sHZnQ99N-Z~%Wc359ld_LTPDdkrwx!?{VAk=yLQ?9b>j| z^+ux9n=p*vLO!<;4kpaiU^@FrM0vrw$^iO>4WnRetl()+RoCCu;y5aca-bAI=*4vxdD~ zLZnP)XagWa;tvr?*O)3lTIZL?Y~3Iz1~B{e0&S~{f;3cDB`Hqp zJ}S9S6e11Q0D~jxFf?i^ZT5R;;%)@0%FQKXZe=k$ZjNBe&s#i$p(YSQzJmKi>?MN@ Kz+n2gmwx~p-=VDl diff --git a/game_engine.py b/game_engine.py index a1fe0ed..dbe22fc 100644 --- a/game_engine.py +++ b/game_engine.py @@ -1,24 +1,31 @@ +"""Import random module""" import random - class GuessingGame: - + """Guessing Game Class""" def __init__(self, num): self.num = num self.answer = random.randint(1,num) self._solved = False - + self.count = 1 def guess(self, user_guess): + """get Guess name and input method""" if user_guess == self.answer: print(f"Congratulations! You solved it. The answer was {self.answer}") + print(f"It only took you {self.count} tries!") self._solved = True - - return self.response(user_guess, "Too high. Try again..") if user_guess >self.answer else self.response(user_guess, "Too Low Try Again") - + + if user_guess > self.answer: + self.response(user_guess, "too high. Try again!") + + if user_guess < self.answer: + self.response(user_guess, "too low. Try again!") + self.count +=1 def response(self, user_guess, message): + """Response of last guess method""" print(f"Oops! Your last guess {user_guess} was {message}") - pass - + def solved(self): - return self._solved \ No newline at end of file + """Solved method to call instance solved""" + return self._solved diff --git a/guessing_game.py b/guessing_game.py index 29511d8..ed3334c 100644 --- a/guessing_game.py +++ b/guessing_game.py @@ -1,7 +1,8 @@ +"""Import game_engine Class""" import game_engine game = game_engine.GuessingGame(10) #1-10 -player_name = (input("Enter your name: ")) +player_name = input("Enter your name: ") print(f"Greetings {player_name}!") From 9ab519807f7071d8f8d2861264a57b51def51a98 Mon Sep 17 00:00:00 2001 From: VaNiesha Honani Date: Mon, 24 Nov 2025 16:39:43 -0800 Subject: [PATCH 3/3] updated atm program --- atm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atm.py b/atm.py index c26cb91..521371a 100644 --- a/atm.py +++ b/atm.py @@ -26,7 +26,7 @@ def is_card_inserted(self,atm_answer): """definition to check if atm card is inserted return True or False """ - if atm_answer == "y": + if atm_answer.lower() == "y": return True else: @@ -51,7 +51,7 @@ def bank_options(self, option): self.withdraw_money() if option == '3': self.deposit_money() - if option == 'x': + if option.lower() == 'x': self.account_logout() def check_balance(self):