diff --git a/__pycache__/bank.cpython-38.pyc b/__pycache__/bank.cpython-38.pyc new file mode 100644 index 0000000..b1dd68c Binary files /dev/null and b/__pycache__/bank.cpython-38.pyc differ diff --git a/__pycache__/bank1.cpython-38.pyc b/__pycache__/bank1.cpython-38.pyc new file mode 100644 index 0000000..6d54644 Binary files /dev/null and b/__pycache__/bank1.cpython-38.pyc differ diff --git a/__pycache__/client.cpython-38.pyc b/__pycache__/client.cpython-38.pyc new file mode 100644 index 0000000..6b01bac Binary files /dev/null and b/__pycache__/client.cpython-38.pyc differ diff --git a/__pycache__/client1.cpython-38.pyc b/__pycache__/client1.cpython-38.pyc new file mode 100644 index 0000000..3a32044 Binary files /dev/null and b/__pycache__/client1.cpython-38.pyc differ diff --git a/bank.py b/bank.py new file mode 100644 index 0000000..b1457ab --- /dev/null +++ b/bank.py @@ -0,0 +1,22 @@ +import time +class Bank: + __clients=[] + def __init__(self,name): + self.name=name + + def add_clients(self,client): + self.__clients.append(client) + + def authentication(self,name,account_number): + for i in range(len(self.__clients)): + if name == self.__clients[i].name and account_number == self.__clients[i].account_number: + time.sleep(1) + print("Authentication successful!") + return self.__clients[i] + print(''' + Authentication failed! + Reason: account not found. + ''') + + def getclients(self): + return self.__clients \ No newline at end of file diff --git a/client.py b/client.py new file mode 100644 index 0000000..dd60a30 --- /dev/null +++ b/client.py @@ -0,0 +1,25 @@ +import random +random_list=list(set(random.randint(10000,99999) for i in range(9999))) +class Client: + i=0 + def __init__(self,name,total_amount): + self.name=name + self.total_amount=total_amount + self.account_number=random_list[Client.i] + Client.i+=1 + def withdrawn(self,amount): + if self.total_amount>=amount: + self.total_amount-=amount + print("The sum of {} has been withdrawn from your account balance.".format(amount)) + self.current_balance() + return self.total_amount + else: + print("Your current account balance is not enough.") + def deposit(self,amount): + self.total_amount+=amount + print("The sum of {} has been added to your account balance.".format(amount)) + self.current_balance() + return self.total_amount + + def current_balance(self): + print ("Your current account balance is: {}".format(self.total_amount)) \ No newline at end of file diff --git a/hackerrank.py b/hackerrank.py new file mode 100644 index 0000000..d66fd3c --- /dev/null +++ b/hackerrank.py @@ -0,0 +1,44 @@ +#1. sWAP cASE: https://www.hackerrank.com/challenges/swap-case/problem +def swap_case(s): + a="" + for i in s: + if i.isupper(): + a+=i.lower() + elif i.islower(): + a+=i.upper() + else: + a+=i + return a + + +if __name__ == '__main__': + s = input() + result = swap_case(s) + print(result) + +# 2. String Split and Join: https://www.hackerrank.com/challenges/python-string-split-and-join/problem +def split_and_join(line): + return '-'.join(line.split(' ')) +if __name__ == '__main__': + line = input() + result = split_and_join(line) + print(result) +# 3. Mutations: https://www.hackerrank.com/challenges/python-mutations/problem +def mutate_string(string, position, character): + return string[:position]+character+string[position+1:] + +if __name__ == '__main__': + s = input() + i, c = input().split() + s_new = mutate_string(s, int(i), c) + print(s_new) +#4. Text Wrap: https://www.hackerrank.com/challenges/text-wrap/problem +import textwrap +def wrap(string, max_width): + return '\n'.join([string[i:i+max_width] for i in range(0,len(string),max_width)]) + + +if __name__ == '__main__': + string, max_width = input(), int(input()) + result = wrap(string, max_width) + print(result) diff --git a/main.py b/main.py new file mode 100644 index 0000000..60db647 --- /dev/null +++ b/main.py @@ -0,0 +1,57 @@ +from client import Client +from bank import Bank +import time + +b1=Bank(input('Name of Bank: ')) + +available=True +while available: + print("Welcome to {}".format(b1.name)) + print("""Choose an option: + 1. Open new bank account + 2. Open existing bank account + 3. Exit + """) + choice=int(input("1,2,3: ")) + if choice==3: + available = False + elif choice==1: + print("To create an account, please fill in the information below.") + name_=input("Name: ") + t_amount=int(input("Total amount: ")) + client1=Client(name_, t_amount) + b1.add_clients(client1) + time.sleep(1) + print("Account created successfully! Your account number is: {}".format(client1.account_number)) + elif choice==2: + print("To access your account, please enter your credentials below.") + account_number=int(input("Account number: ")) + name=input("Name: ") + client_authentication=b1.authentication(name,account_number) + if client_authentication: + authorized = True + print("Bank account is opening...") + time.sleep(1) + print('Welcome {}'.format(name)) + while authorized: + print("""Choose an option: + 1. Withdraw + 2. Deposit + 3. Balance + 4. Exit""") + choice1=int(input("Choice: ")) + if choice1==1: + w_amount = int(input("Withdraw amount:")) + client_authentication.withdrawn(w_amount) + elif choice1==2: + d_amount = int(input("Deposit amount:")) + client_authentication.deposit(d_amount) + elif choice1==3: + client_authentication.current_balance() + elif choice1==4: + authorized=False + + else: + time.sleep(1) + print('Authentication failed! \nReason: account is not found') + diff --git a/q1.2.png b/q1.2.png new file mode 100644 index 0000000..fcc6c9e Binary files /dev/null and b/q1.2.png differ diff --git a/q2.png b/q2.png new file mode 100644 index 0000000..4b71d7c Binary files /dev/null and b/q2.png differ diff --git a/q3.png b/q3.png new file mode 100644 index 0000000..9c67177 Binary files /dev/null and b/q3.png differ