Esempio n. 1
0
    def realitza_pagament(Usuario):

        pagament_correcte = B.Bank()
        confirm = pagament_correcte.do_payment(Usuario, Usuario.Pagament)

        #pagament_correcte = True
        pagamentOk = False
        if (confirm == False):
            # Reintentamos confirmar la reserva de vuelos... suponemos que no
            confirmacion = 1
            while (confirmacion <= 3):

                confirm = pagament_correcte.do_payment(Usuario,
                                                       Usuario.Pagament)
                #pagament_correcte=True
                if (confirm):
                    pagamentOk = True
                    break
                else:
                    confirmacion = confirmacion + 1

            if (pagamentOk == False):
                print(
                    "Ha habido un problema durante el proceso de confirmacion del pagament, no se ha efectuado ningun cargo"
                )
        else:
            pagamentOk = True

        return pagamentOk  #TRUE OR FALSE
Esempio n. 2
0
 def testAddFundsInt(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 10)
     testUser.login("username", "pass")
     testAccount = Account(testUser, "account1")
     testAccount.addFunds(33)
     self.assertEqual(testAccount.getFunds(), 33)
Esempio n. 3
0
 def setup(self):
     checking_account = CheckingAccount(G.player_initial_money,
                                        self.env)  # a checking acount
     saving_account = SavingAccount(0, self.env)  # a saving account
     self.player.set_bank_account(
         checking_account,
         saving_account)  #give the above accounts to the player
     self.bank = Bank(self.player)  #set up the bank
Esempio n. 4
0
 def __init__(self):
     self.players = []
     self.currentPlayer = None
     self.board = Board()
     self.chancePile = ChanceCards()
     self.communityPile = CommunityCards()
     self.dice = TwoDice()
     self.bank = Bank()
Esempio n. 5
0
    def __init__(self):

        self.bank = Bank.Bank()
        self.inventory = Inventory.Inventory()
        self.dayCounter = 0
        self.servedCustomers = 0
        self.satisfiedCustomers = 0
        self.popularity = 0
        self.cost = 0
Esempio n. 6
0
 def __init__(self):
     self.players = []
     self.currentPlayer = None
     self.board = Board()
     self.chancePile = ChanceCards()
     self.communityPile = CommunityCards()
     self.dice = TwoDice()
     self.bank = Bank()
     """Instance variables for the Controller"""
     self.gameMessages = None
     self.controllerInput = None
     self.functionCallName = None
     self.supportingData = None
Esempio n. 7
0
def main():
    # 欢迎页面
    AdminView.printWelcomeView()
    # 进入登陆页面
    if AdminView.checkUserAndPassword() == -1:
        return -1

    # 获取用户信息:通过本地文件读取已存在用户列表
    # allUser.txt:存储用户信息的文件
    # 假设用户数量为空
    allUser = {}
    if os.path.getsize("allUser.txt") > 0:
        with open("allUser.txt", "rb") as f1:
            # 已经存在用户
            allUser = pickle.load(f1)
    print(allUser)
    # 银行的对象只有一个
    bank = Bank.Bank(allUser=allUser)
    # 进入主程序页面
    while True:
        time.sleep(1)
        AdminView.mainFunctionView()
        checkFunc = input("请按照数字输入选择的功能")
        if checkFunc == "1":
            bank.createUser()
        elif checkFunc == "2":
            bank.seachUser()
        elif checkFunc == "3":
            bank.getMoney()
        elif checkFunc == "4":
            bank.saveMoney()
        elif checkFunc == "5":
            bank.changePassword()
        elif checkFunc == "6":
            bank.createOtherCard()
        elif checkFunc == "7":
            bank.lockedCard()
        elif checkFunc == "8":
            bank.unlockedCard()
        elif checkFunc == "9":
            bank.cancelUser()
        elif checkFunc == "z":
            bank.transferMoney()
        elif checkFunc == "0":
            # 存入或更新数据
            with open("allUser.txt", "wb") as f1:
                pickle.dump(bank.allUser, f1)
            return 0
        else:
            print("输入错误,请确认后重新输入")
Esempio n. 8
0
def main():
    myBank = Bank("TD Bank")
    

    print(myBank)
    print("total funds: " + str(myBank.getMoneyInBank()))

    myBank.depositIntoAccount
    myBank.depositIntoAccount
    myBank.withdrawFromAccount
    myBank.withdrawFromAccount

    print(myBank)
    print("total funds: " + str(myBank.getMoneyInBank()))
Esempio n. 9
0
    def test_bank_2(self):
        test_bank = Bank.Bank()
        test_bank.add_entry(123456789, 1234, "checking", 1000)
        test_bank.add_account(123456789, "savings", 1000)
        test_bank.add_entry(987654321, 7321, "checking", 5000)
        test_atm = ATM.ATM(test_bank, 10000)
        cash_bin_over_action = [("See Balance", 0), ("Withdraw", 30000)]

        # Tests cash bin excess handling on account balance
        self.assertEqual(
            test_atm(987654321, 7321, "checking", cash_bin_over_action),
            "Actions completed")

        exit_action = [("See Balance", 0), ("Leave", 0)]
        self.assertEqual(test_atm(987654321, 7321, "checking", exit_action),
                         "Gracefully departed")
Esempio n. 10
0
    def test_bank_1(self):
        test_bank = Bank.Bank()
        test_bank.add_entry(123456789, 1234, "checking", 1000)
        test_bank.add_account(123456789, "savings", 1000)
        test_bank.add_entry(987654321, 7321, "checking", 5000)
        test_atm = ATM.ATM(test_bank, 10000)
        action_list = [("See Balance", 0), ("Withdraw", 40),
                       ("Withdraw", 1000), ("Deposit", 100)]

        # These next test should be a correctly executing test case
        self.assertEqual(test_atm(987654321, 7321, "checking", action_list),
                         "Actions completed")

        # Tests whether ATM handles overdraft attempt without crashing
        self.assertEqual(test_atm(123456789, 1234, "checking", action_list),
                         "Actions completed")

        # Test incorrect PIN number
        self.assertEqual(test_atm(987654321, 1234, "checking", action_list),
                         "Invalid Card or Incorrect Pin!")

        # Test incorrect Account number
        self.assertEqual(test_atm(876504321, 1234, "checking", action_list),
                         "Invalid Card or Incorrect Pin!")
Esempio n. 11
0
from Bank import *
from Client import *

bank = Bank("moj_bank")
bank2 = Bank("moj_bank2")
client1 = Client("Andrzej", "Kowalski")
client2 = Client("Anna", "Nowak")
client3 = Client("Grzegorz", "Aaaa")
client4 = Client("Katarzyna", "Bbbb")

bank.add_client(client1)
bank.add_client(client2)

bank2.add_client(client3)
bank2.add_client(client4)

client1.add_money(200)
client1.remove_money(50)
client1.add_money(2)
client2.add_money(1200)
client3.add_money(15000)
client4.add_money(160)
print('Show client - bank')
bank.show_all_clients()
print('\nShow client - bank2')
bank2.show_all_clients()

print('\nShow money')
client1.cash()
client2.cash()
print('\nAfter transfer')
Esempio n. 12
0
from Bank import *

bank1 = Bank(1, "Stanbic", "Makerere", "00-0009")
bank2 = Bank(2, "DFCU", "Wandegeya", "00-4509")

#Tellers for bank 1
teller1A = Teller(1, "Yazid", bank1)
teller1B = Teller(2, "Peter", bank1)
teller1C = Teller(3, "Alex", bank1)

#Tellers for bank2
teller2A = Teller(1, "Moses", bank2)
teller2B = Teller(2, "Kalungi", bank2)
teller2C = Teller(3, "Isanka", bank2)

customer = Customer(1, "miiro", "Lumumba", 900877)
customer.OpenAccount(teller1A, "savings")

customer2 = Customer(1, "miiro", "Lumumba", 900877)
customer2.OpenAccount(teller1A, "savings")

customer2.DepositMoney(4000, teller1A)
customer2.WithdrawMoney(4000, teller1A)

customer.ApplyForLoan(teller1A, 100000)
customer.Loan.pay_loan(4000)
Esempio n. 13
0
print(select)

# Exchange n for Blum Gold
# Send over bank's public key
# Generate Keys
n, a, b, p, q = enc.get_Blum_Gold_Keys()
print("Sending over public key n:", n)
send = str(n)
c.send(send.encode("utf-8"))
s
# Get ATM's public key
msg = c.recv(1024).decode()
n_ATM = int(msg)
print("Recieved ATM's public key:", n_ATM)

bank = Bank.Bank(name)  # <== Put the ATM users name here

# Read the Messages from the ATM
while (True):
    # Get the message
    data = c.recv(1024).decode()
    data_no_mac = data[:data.index("M") - 1]
    print("Recieved:", data)
    # Decrypt
    if (select == "BLUM"):
        msg = enc.Blum_Gold_Decrypt(n, a, b, p, q, data)
    elif (select == "DES"):
        msg = DES.decrypt(data_no_mac, key)
    else:
        # 3 DES
        msg = DES.decrypt3(data_no_mac, key)
Esempio n. 14
0
from BankAccount import*
from Bank import*
from Employee import*
from Manager import*

bank = Bank("Interco Bank", 500)
(interco, bankId, intercoCash) = bank.createBankAccount("Interco", 20000000)
man = Manager("Hhhm", 10000000, 10000, "BeastMaster")
print("Manager %s pay %.2f" % (man.getFormattedName(), man.calculatePay()))
(name, bankId, cash) = bank.createBankAccount(man.getFormattedName(), 200000)
print("%s account %.2f" % (name, cash))
try:
    bank.transfer(bank.accounts[interco],
                 bank.accounts[name], man.calculatePay())
    print("%s account %.2f" % (name, bank.accounts[name].cash))
except InsufficientFundsError:
    print("We can't pay you :(")
    print("%s account %.2f" % (interco, bank.accounts[interco].cash))
print("%s transactions %s" % (name, bank.transactions[name].print()))
emp = Employee("Julia", 200000)
print("Employee %s pay %.2f" % (emp.getFormattedName(), emp.calculatePay()))
(name, bankId, cash) = bank.createBankAccount(emp.getFormattedName(), 20000)
print("%s account %.2f" % (name, cash))
try:
    bank.transfer(bank.accounts[interco],
                 bank.accounts[name], emp.calculatePay())
    print("%s account %.2f" % (name, bank.accounts[name].cash))
except InsufficientFundsError:
    print("We are broke :(")
    print("%s account %.2f" % (interco, bank.accounts[interco].cash))
Esempio n. 15
0
 def test_empty_bank(self):
     empty_bank = Bank.Bank()
     empty_atm = ATM.ATM(empty_bank, 0)
     valid, message = empty_atm.swipe(0, 0)
     self.assertEqual(valid, 0)
Esempio n. 16
0
class AtmApplication():
    """ Class that handels user input """
    #initalize field variables
    _bank = Bank()
    _acctNo = 0
    _ivalidInput = "Invalid Input. Please enter a valid number\n"

    def __init__(self):
        #here for python convention
        pass

    def run(self):
        """starts the ATM"""
        while True:
            print("Main Menu\n")
            print("1: Select Account")
            print("2: Create Account")
            print("3: Exit\n")
            try:
                choice = int(input("Enter a choice: "))
                if choice == 1:
                    self.onSelectAccount()
                elif choice == 2:
                    self.onCreateAccount()
                elif choice == 3:
                    break
                else:
                    print(
                        "Please enter a valid number.\nEnter 1 to select an account.\nEnter 2 to create an account.\nEnter 3 to exit.\n"
                    )
                    continue
            except ValueError:
                print("Invalid Input. Please enter a valid number\n")

    def onCreateAccount(self):
        """When Create Account is selected"""
        while True:
            try:
                clientName = input(
                    "Please enter the client name or press [ENTER] to cancel: "
                )
                if clientName == "":
                    break
                balanceInput = input(
                    "Please enter your intial balance or press [ENTER] to cancel: "
                )
                if balanceInput == "":
                    break
                elif int(balanceInput) < 0:
                    print("Please enter a number grater than 0\n")
                    continue
                else:
                    balance = int(balanceInput)
                accountType = input(
                    "Please enter the account type [c/s: chequing / savings]: "
                )
                if accountType == "":
                    break
                elif len(accountType) > 1:
                    print("Please enter a [c or s] to select an account\n")
                    continue
                elif ord(accountType) != 67 and ord(accountType) != 99 and ord(
                        accountType) != 83 and ord(accountType) != 115:
                    print("Please enter a [c or s] to select an account\n")
                    continue
                if ord(accountType) == 67 or ord(accountType) == 99:

                    interRateInput = float(
                        input(
                            "Please enter the interest rate for this account: "
                        ))
                    if interRateInput == "":
                        break
                    elif float(interRateInput) < 0:
                        print("Please enter a number greater than 0\n")
                        continue
                    elif float(interRateInput) > 1:
                        print("Please enter a number less than 1\n")
                        continue
                    else:
                        interRate = float(interRateInput)
                elif ord(accountType) == 83 or ord(accountType) == 115:
                    interRateInput = float(
                        input(
                            "Please enter the interest rate for this account: "
                        ))
                    if interRateInput == "":
                        break
                    elif float(interRateInput) < 3:
                        print("Please enter a number greater than 3\n")
                        continue
                    else:
                        interRate = float(interRateInput)

                acctNoInput = int(
                    input(
                        "Please enter the account number [100 - 1000] or press [ENTER] to cancel: "
                    ))
                if acctNoInput == "":
                    break
                elif int(acctNoInput) < 100 or int(acctNoInput) > 1000:
                    print(
                        "Please enter a value a number between [100 - 1000]\n")
                    continue
                else:
                    acctNo = int(acctNoInput)

                if self._bank.getAccount(acctNo) != None:
                    print("Account number already exists")
                    continue
                else:
                    self._bank.openAccount(acctNo, clientName, balance,
                                           accountType, interRate)
                    break
            except ValueError:
                print("Invalid Input. Please enter a valid input\n")

    def onSelectAccount(self):
        """When select account is created"""
        while True:
            try:
                if self._acctNo == 0:
                    acctNo = input(
                        "Please enter your account ID or press [ENTER] to cancel: "
                    )

                    if acctNo == "":
                        break
                    else:
                        self._acctNo = int(acctNo)
                    if self._bank.getAccount(self._acctNo) == None:
                        print("ID not found!\n")
                        self._acctNo = 0
                        return
                else:
                    print("Account Menu\n")
                    print("1: Check Balance")
                    print("2: Withdraw")
                    print("3: Deposit")
                    print("4: Predict Balance")
                    print("5: Exit\n")

                    choice = int(input("Enter a choice: "))

                    if choice == 1:
                        self.onCheckBalance()
                    elif choice == 2:
                        self.onWithdraw()
                    elif choice == 3:
                        self.onDeposit()
                    elif choice == 4:
                        self.onPredictBalance()
                    elif choice == 5:
                        self._acctNo = 0
                        break
                    else:
                        print(
                            "Please enter a valid number.\nEnter 1 to chack balance.\nEnter 2 to withdraw from account.\nEnter 3 to deposit into account.\nEnter 4 to predict balance.\nEnter 5 to exit.\n"
                        )
                        continue
            except ValueError:
                print("Invalid Input. Please enter a valid number\n")

    def onCheckBalance(self):
        """When check balance is selected"""
        account = self._bank.getAccount(self._acctNo)
        print("Current balance: " + str(account.getBalance()))
        return

    def onDeposit(self):
        """When deposit is selected"""
        account = self._bank.getAccount(self._acctNo)
        amount = int(input("How much money would you like to deposit: "))
        account.deposit(amount)
        print("New balance is: " + str(account.getBalance()))
        return

    def onWithdraw(self):
        """When withdraw is selected"""
        account = self._bank.getAccount(self._acctNo)
        amount = int(input("How much money would you like to withdraw: "))
        if amount > account.getBalance():
            print("Insufficent funds!")
            return
        else:
            account.withdraw(amount)
            print("New balance is: " + str(account.getBalance()))
            return

    def onPredictBalance(self):
        """when predict balancce is selected"""
        while True:
            try:
                monthlyDeposit = int(input("Please enter a monthly deposit: "))
                if monthlyDeposit < 0:
                    print("Please enter a valid amount")
                    continue
                monthlyWithdrawl = int(
                    input("Please enter a monthly withdrawl: "))
                if monthlyWithdrawl < 0:
                    print("Please enter a valid amount")
                    continue

                account = self._bank.getAccount(self._acctNo)
                print("Account Number: " + str(account.getAccountNumber()))
                print("Name: \t\t" + account.getAccountHolderName())
                balance = account.getBalance()
                newInterest = 0.0
                #for 12 months
                for i in range(0, 12):
                    balance = balance + monthlyDeposit - monthlyWithdrawl
                    interst = account.predictBalance(balance)
                    newInterest += interst
                    print("Month " + str(i + 1) + ":")
                    print("\tBalance: " + str(round(balance, 2)))
                    print("\tInterest: " + str(round(newInterest, 2)))
                print("End of the Year Balance: " +
                      str(round((newInterest + balance), 2)))
                break
            except ValueError:
                print("Invalid Input. Please enter a valid number\n")
Esempio n. 17
0
 def testConstructor(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 10)
     testBox = DepositBox(testUser, 3, ["hat"])
     self.assertEqual(testBox.getContents()[0], "hat")
Esempio n. 18
0
 def testConstructorFundsFloat(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 10.989)
     self.assertEqual(testUser.getPersonalFunds(), 10.99)
Esempio n. 19
0
	def load_bank(self, user):
		return Bank.Bank(user)
Esempio n. 20
0
 def testConstructorFundsZero(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 0)
     self.assertEqual(testUser.getPersonalFunds(), 0)
Esempio n. 21
0
 def __init__(self):
     self.bank = Bank()
     self.listCustomer = []
Esempio n. 22
0
 def testLoginValid(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 0)
     self.assertEqual(testUser.login("username", "pass"), True)
Esempio n. 23
0
 def testLoginInvalid(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 0)
     self.assertEqual(testUser.login("penguin", "123"), False)
Esempio n. 24
0
 def testRegisterDepositBox(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 0)
     testUser.registerDepositBox(5, ["shoe"])
     self.assertEqual(testUser.getDepositBoxes()[0].getContents(), ["shoe"])
Esempio n. 25
0
        elif ch == 'cl':
            ac = bank.close_account(ac)
        elif ch == 'f':
            am = raw_input('Enter amount to add: ')
            ac.change_balance(am)
        elif ch == 'l':
            bank.list_all_accounts()
        elif ch == 'n':
            ac.print_current_accout()
        elif ch == 's':
            ac = bank.change_account()
        elif ch == 'w':
            am = raw_input('Enter amount to withdraw: ')
            ac.change_balance(-float(am))
        elif ch == 'x':
            return False
            #break
        else:
            print('Input not recognized!')


if __name__ == '__main__':
    pass

from Bank import *

bank = Bank()

ac = bank.add_account()
main_loop(ac)
Esempio n. 26
0
 def testCreateAccount(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 0)
     testUser.createAccount("account1")
     self.assertEqual(testUser.getAccounts()[0].getId(), "account1")
Esempio n. 27
0
 def __init__(self, name, starting_amount=40):
     super().__init__(name)
     self.Bank = Bank(starting_amount)
     self.bet_amount = 0
Esempio n. 28
0
 def testAccountConstructor(self):
     testBank = Bank("Test Bank")
     testUser = User(testBank, "username", "pass", 10)
     testAccount = Account(testUser, "account1")
     self.assertEqual(testAccount.getId(), "account1")
Esempio n. 29
0
def main():
    quitProgram = False
    loginChoice = ""
    bankChoice = ""
    loggedIn = False
    bankSelected = False


    # Create bank objects
    bank1 = Bank("TD Bank")
    bank2 = Bank("Passumpsic Bank")
    bank3 = Bank("Community National Bank")
    banks = [bank1, bank2, bank3]
    mainBank = banks[0]
    mainUser = User(bank1, "", "", 10)

    print("Welcome, please select the bank you would like to use: ")

    while not bankSelected:
        for i in range(len(banks)):
            print(str(i + 1) + ". " + banks[i].getName() + " \n")

        bankChoice = input("Your Selection: ")

        try:
            if int(bankChoice) - 1 < len(banks) and int(bankChoice) - 1 >= 0:
                mainBank = banks[int(bankChoice) - 1]
                bankSelected = True
        except ValueError:
            print("Input was invalid, try again.")

    print("Welcome to " + mainBank.getName() + ".")
    print("Would you like to login as an existing user, or register?")

    # Handle account creation and login
    while not loggedIn:
        print("Please select from the following options: ")
        print("1. Register user account \n2. Login \n")
        loginChoice = input("Your Selection: ")

        # Get input to register new account
        if loginChoice == "1":
            usernameChoice = input("Please enter your username: "******"Please enter your password: "******"Please enter your personal funds: ")
            newUser = User(mainBank, usernameChoice, passwordChoice, int(personalFundsChoice))
            newUser.login(usernameChoice, passwordChoice)
            mainBank.registerUser(newUser)
            print("Your user profile has been created, " + usernameChoice)
            loggedIn = True

        # Attempt to login to existing account
        elif loginChoice == "2":
            usernameChoice = "0"
            passwordChoice = "0"

            while not loggedIn and usernameChoice != "" and passwordChoice != "":
                print("To go back, enter nothing for either field.")
                usernameChoice = input("Please enter your username: "******"Please enter your password: "******"" and passwordChoice != "":
                    for user in mainBank.getUsers():
                        if user.login(usernameChoice, passwordChoice):
                            print("You have successfully logged in, " + usernameChoice)
                            mainUser = user
                            loggedIn = True
                            break
                    if not loggedIn:
                        print("Your credentials were incorrect, please try again.")

    print("You are now logged in.")

    # Interface with accounts and deposit boxes for the selected user
    userMenuChoice = ""
    quitProgram = False

    while not quitProgram:
        print("\nPlease select from the following user options, or enter 'q' to log out. ")
        print("1. Create Account \n2. Select Account \n3. Register Deposit Box \n4. Select Deposit Box \n5. Check Personal Funds ")
        userMenuChoice = input("Your Selection: ")

        # Account creation
        if userMenuChoice == "1":
            newAccountName = input("Please enter the new account's name: ")
            mainUser.createAccount(newAccountName)
            print("Account '" + newAccountName + "' has been created. ")

        # Account selection
        elif userMenuChoice == "2":
            print("\nPlease select one of your accounts, or enter nothing to go back. ")
            for i in range(len(mainUser.getAccounts())):
                print(str(i + 1) + ". " + mainUser.getAccounts()[i].getId())
            accountChoice = input("Your Selection: ")
            mainAccount = ""
            mainAccountIndex = 0
            accountSelected = False

            # Validate selection input
            while not accountSelected and accountChoice != "":
                try:
                    if int(accountChoice) - 1 < len(mainUser.getAccounts()) and int(accountChoice) - 1 >= 0:
                        mainAccount = mainUser.getAccounts()[int(accountChoice) - 1]
                        mainAccountIndex = int(accountChoice) - 1
                        accountSelected = True
                except ValueError:
                    print("Input was invalid, try again.")

            # Handle checking, withdrawing and depositing
            if accountSelected:
                print("\nPlease select an action for this account, or enter nothing to go back. ")
                print("1. Check Balance \n2. Withdraw Funds \n3. Deposit Funds ")
                subAccountChoice = input("Your Selection: ")

                if subAccountChoice == "1":
                    print("Account Balance: " + str(mainAccount.getFunds()))

                elif subAccountChoice == "2":
                    amount = input("Please enter an amount to withdraw: ")
                    mainUser.addFundsToAccount(float(amount) * -1, mainAccountIndex)

                elif subAccountChoice == "3":
                    amount = input("Please enter an amount to deposit: ")
                    mainUser.addFundsToAccount(float(amount), mainAccountIndex)

        # Create deposit box
        elif userMenuChoice == "3":
            depositItemChoice = ""
            itemList = []
            itemCount = 0
            print("\nThe maximum capacity of your new deposit box is " + str(mainBank.getMaxDepositBoxCapacity()))
            print("Please enter the contents of the new deposit box one by one, enter 'f' when finished.")

            while depositItemChoice != "f" and itemCount < mainBank.getMaxDepositBoxCapacity() - 1:
                itemCount += 1
                depositItemChoice = input("Please enter an item: ")

                if depositItemChoice != "f":
                    itemList.append(depositItemChoice)
            mainUser.registerDepositBox(mainBank.getMaxDepositBoxCapacity(), itemList)
            print("Your new deposit box has been registered. ")

        # Select deposit box
        elif userMenuChoice == "4":
            print("\nPlease select one of your deposit boxes, or enter nothing to go back. ")
            for i in range(len(mainUser.getDepositBoxes())):
                print("Deposit box #" + str(i + 1))
            boxChoice = input("Your Selection: ")
            mainBox = ""
            mainBoxIndex = 0
            boxSelected = False

            while not boxSelected and boxChoice != "":
                try:
                    if int(boxChoice) - 1 < len(mainUser.getDepositBoxes()) and int(boxChoice) - 1 >= 0:
                        mainBox = mainUser.getDepositBoxes()[int(boxChoice) - 1]
                        mainBoxIndex = int(boxChoice) - 1
                        boxSelected = True
                except ValueError:
                    print("Input was invalid, please try again.")

            # Handle checking, withdrawing, and depositing in a deposit box
            if boxSelected:
                print("\nPlease select an action for this deposit box, or enter nothing to go back. ")
                print("1. Check Box \n2. Withdraw item \n3. Deposit item ")
                subBoxChoice = input("Your Selection: ")

                if subBoxChoice == "1":
                    print("Box contents: " + str(mainBox.getContents()))

                elif subBoxChoice == "2":
                    print("The box contents are as follows. ")
                    for i in range(len(mainBox.getContents())):
                        print(str(i) + ". " + mainBox.getContents()[i])
                    withdrawalItemIndex = int(input("Please enter the number of the item you wish to withdraw: "))

                    if withdrawalItemIndex >= 0 and withdrawalItemIndex < len(mainBox.getContents()):
                        mainUser.removeItemFromBox(withdrawalItemIndex, mainBoxIndex)
                        print("Item removed.")

                elif subBoxChoice == "3":
                    newBoxItem = input("Please enter an item to deposit: ")
                    mainUser.addItemToBox(newBoxItem, mainBoxIndex)
                    print("Item added.")

        elif userMenuChoice == "5":
            print("Your personal funds are: " + str(mainUser.getPersonalFunds()))

        elif userMenuChoice == "q":
            mainUser.logout()
            quitProgram = True
Esempio n. 30
0
    print('Dealer Wins')


def push(player, dealer):
    print('Dealer and player tie! PUSH!')


while True:
    # Openning statement

    print("W E L C O M E  T O  B L A C K J A C K")
    deck = Deck()
    deck.shuffle_deck()
    player = Player.Player()
    dealer = Dealer.Dealer()
    bank = Bank.Bank(500, 500)
    # if the player or dealer have no cards, they will draw 2 cards each.
    if player.is_empty() == True:
        for i in range(2):
            player.draw_card(deck.deal_card())

    if dealer.is_empty() == True:
        for i in range(2):
            dealer.draw_card(deck.deal_card())
    while game:  # from hit_or_stand func
        # ask the player if he wants to hit or stand
        hit_or_stand(deck, player)

        # shows the cards.
        show_some(dealer, player)