From f671df20dfdb097bc1ebeb4e100244ebe30d638f Mon Sep 17 00:00:00 2001 From: shahanamalik <69112714+shahanamalik@users.noreply.github.com> Date: Sun, 25 Apr 2021 08:03:36 +0500 Subject: [PATCH 1/2] Add files via upload --- ATM.py | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 ATM.py diff --git a/ATM.py b/ATM.py new file mode 100644 index 0000000..4690a97 --- /dev/null +++ b/ATM.py @@ -0,0 +1,104 @@ +import random +customer_database = {} +def init(): + print("Welcome to Pak Bank!") + from datetime import datetime + today = datetime.today() +def login(): +print('Welcome,what would you like to select?') +print("1, login") +print("2, register") +actionselect = int(input("Select an option \n")) +if(actionselect == 1): + isLoginSuccessful == False + while isLoginSuccessful == False: + isLoginSuccessful = Login() + bankOperations() +else: + print('Invalid Option Selected, please try again') + if (account_number == 1): + login() + elif(account_number == 2): + register() + else: + print("invalid selection") +init() + +def register(): + print('Create your unique bank account with us. \n') + email = input('What is your email address? \n') + global first_name + first_name = input('What is your first name? \n') + global last_name + last_name = input('What is your last name? \n') + password = input('Create your unique password. \n') + + + account_number = account_number_generator() + + + user_details = [email, first_name, last_name, password] + + + + customers_database[account_number] = [first_name, last_name, email, password] + + + print('Your account has been created.') + print(' == ==== ==== ==== ==== ==== ==') + print('This is your account number: {account_number}') + print(' == ==== ==== ==== ==== ==== == ') + print('Make sure to keep it safe. \n') + + + login() + + +def login(): + print('Login to your account. \n') + user_account_number = int(input('What is your account number? \n')) + password = input('What is your password? \n') + + + for account_number,user_details in customers_database.items(): + if account_number == user_account_number: + if user_details[3] == password: + bank_operations(user_details) + + + print('Invalid account number or password') + login() + + +def bank_operations(user): + print('Dear {first_name} {last_name}. \n') +print('These are the options available: ') +print('1, withdraw') +print('2, Cash deposit') +print('3, complaint') +choice = int(input('Select Option: ')) +if choice == 1: + pay = int(input('How much would you like to withdraw?: ')) + print("take your cash: " + str(pay)) + +elif choice == 2: + collect = int(input('How much would you like to deposit?: ')) + print('Balance is: '+ str(collect)) + +elif choice == 3: + complaint = str(input('What issue will you like to report?: ')) + print("Thank you for contacting us") +else: + print('Invalid Option Selected, please try again') + +def account_number_generator(): + return random.randrange(1000111111,9999999999) + + +def logout(): + login() + + +init() + + From 37faa5907283ee70ef871df469a375a17277aa04 Mon Sep 17 00:00:00 2001 From: shahanamalik <69112714+shahanamalik@users.noreply.github.com> Date: Sun, 30 May 2021 01:52:52 +0500 Subject: [PATCH 2/2] Add files via upload --- Budget.py | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Budget.py diff --git a/Budget.py b/Budget.py new file mode 100644 index 0000000..90b7967 --- /dev/null +++ b/Budget.py @@ -0,0 +1,105 @@ +class Budget: + class Food: + def __init__(self, balance): + self.bal = balance + + def getBalance(self): + return self.bal + + def setBalance(self, value): + self.bal = value + + +class Clothing: + def __init__(self, balance): + self.bal = balance + + def getBalance(self): + return self.bal + + def setBalance(self, value): + self.bal = value + + +class Entertainment: + def __init__(self, balance): + self.bal = balance + + def getBalance(self): + return self.bal + + def setBalance(self, value): + self.bal = value + + +class Budget: + def __init__(self): + """Instantiate the food, clothing ang entertainment class and initialize them with a balance of zero""" + self.food = Food(0) + self.clothing = Clothing(0) + self.entertainment = Entertainment(0) + self.pairs = {"food": self.food, + "clothing": self.clothing, + "entertainment": self.entertainment + } + + def categoryIsValid(self, category): + """Verifies if the category is valid""" + if category in self.pairs: + return True + return False + + def deposit(self, amount, categ): + """Deposit into the specified category""" + if self.categoryIsValid(categ) == True: + category = self.pairs[categ] + curBal = category.getBalance() + balAfterDeposit = amount + curBal + category.setBalance(balAfterDeposit) + print("Deposit successful.") + else: + print("Invalid category.") + + def withdrawal(self, amount, categ): + """Withdraws from the specified category""" + if self.categoryIsValid(categ) == True: + category = self.pairs[categ] + curBal = category.getBalance() + if curBal < amount: + print("Error. Insufficient funds.") + else: + balAfterWithdrawal = curBal - amount + category.setBalance(balAfterWithdrawal) + print("Take your cash...#{amount}") + else: + print("Invalid category.") + + def showCategoryBalances(self): + """Displays balance for all categories""" + foodBalance = self.food.getBalance() + clothingBalance = self.clothing.getBalance() + entertainmentBalance = self.entertainment.getBalance() + print("The balance for the food category is: {foodBalance}") + print("The balance for the clothing category is: {clothingBalance}") + print("The balance for the entertainment category is: {entertainmentBalance}") + + def transfer(self, amount, srcCateg, destCateg): + """Tranfers from the source category to another category""" + if (self.categoryIsValid(srcCateg) and self.categoryIsVald(destCateg)) == True: + src, dest = self.pairs[srcCateg], self.pairs[destCateg] + srcBalance = src.getBalance() + if srcBalance >= amount: + srcRemBalance = srcBalance - amount + src.setBalance(srcRemBalance) + destCurBalance = dest.getBalance() + destFinBalance = destCurBalance + amount + dest.setBalance(destFinBalance) + print("Transfer Succesful.") + else: + print("Error. Insufficient funds.") + else: + print("Invalid category.") + + +#Instantiate the Budget Class +