Beispiel #1
0
def qbasic():
    global atmOn, accountsList, transactionSummary, totalAmount, deletedAccounts, newlyCreatedAccounts, testMode

    userInput = Console()
    # tester = Validity()
    currentSession = Session()
    actions = Actions()

    # infinite loop while bank machine is "on"
    while atmOn == True:
        # retrieve user input
        try:
            cmd = userInput.commandInput(testMode)
        except EOFError:
            cmd = "off"

        # go through the possible input cases
        if cmd == "off":
            atmOn = False
            # ends the program
        elif (cmd == "ignore"):
            # input was invalid, do nothing
            pass
        elif (cmd == "login"):
            currentSession.login(testMode)
        elif (cmd == "logout"):
            currentSession.logout(transactionSummary)
            totalAmount = 0  # reset session's totalAmount
        elif (cmd == "create"):
            accountNumber = 0000000
            if (currentSession.loggedInAgent == True):
                accountNumber = userInput.accountNumberInput(testMode)
                if accountNumber == "ignore":
                    continue
                newlyCreatedAccounts.append(int(accountNumber))
            actions.create(currentSession, transactionSummary, accountsList,
                           deletedAccounts, accountNumber, testMode)
        elif (cmd == "delete"):
            accountNumber = 0000000
            if (currentSession.loggedInAgent == True):
                accountNumber = userInput.accountNumberInput(testMode)
                if accountNumber == "ignore":
                    continue
                deletedAccounts.append(int(accountNumber))
            actions.delete(currentSession, transactionSummary, accountsList,
                           accountNumber, deletedAccounts,
                           newlyCreatedAccounts, testMode)
        elif (cmd == "deposit"):
            actions.deposit(currentSession, transactionSummary,
                            deletedAccounts, newlyCreatedAccounts,
                            accountsList, testMode)
        elif (cmd == "withdraw"):
            accountNumber = 0000000
            amount = 0
            if (currentSession.loggedInGeneral == True):
                accountNumber = userInput.accountNumberInput(testMode)
                if accountNumber == "ignore":
                    continue
                amount = userInput.amountInput(testMode, currentSession)
                if amount == "ignore":
                    continue
                totalAmount += int(amount)
            actions.withdraw(currentSession, transactionSummary, accountNumber,
                             amount, totalAmount, deletedAccounts,
                             newlyCreatedAccounts, accountsList, testMode)
        elif (cmd == "transfer"):
            actions.transfer(currentSession, transactionSummary, accountsList,
                             deletedAccounts, newlyCreatedAccounts, testMode)

    transactionSummary.close()