Example #1
0
        public int displayMenu()
        {
            int choose = 0;

            int[] amount = { 20, 40, 60, 80 };
            while (choose == 0)
            {
                UserScreen.DisplayMessage("Menu\n");
                UserScreen.DisplayMessage("1.$20\n\n");
                UserScreen.DisplayMessage("2.$40\n\n");
                UserScreen.DisplayMessage("3.$60\n\n");
                UserScreen.DisplayMessage("4.$80\n\n");
                UserScreen.DisplayMessage("Choose a withdrawal amount");
                int temp = keypad.GetInput();
                switch (temp)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    choose = amount[temp];
                    break;

                case 6:
                    choose = CANCELED;
                    break;

                default:
                    UserScreen.DisplayMessage("Its not example. Please try again");
                    break;
                }
            }
            return(choose);
        }
Example #2
0
        // islem yapilabiliyor mu
        private bool IsWithrawal(int val)
        {
            // cekebilecegin para var mi?
            if (val <= Database.getAvaibleBalance(AccountNumber))
            {
                // ATM de para var mi
                if (cashDispenser.IsSufficiantCashAvaible(val))
                {
                    Database.Debit(AccountNumber, val);
                    cashDispenser.DispenseCash(val);
                    return(true);
                }
                else
                {
                    UserScreen.DisplayMessageLine("ERROR: money in ATM is not enough!");
                    UserScreen.Sleep(3000);
                }
            }
            else
            {
                UserScreen.DisplayMessage("\nERROR: your avaible balance: ");
                UserScreen.DisplayDollarAmount(Database.getAvaibleBalance(AccountNumber));
                UserScreen.Sleep(2000);
            }

            return(false);
        }
Example #3
0
        public override void Execute()
        {
            amount = PrompForDepositAmount();
            if (amount != CANCELED)
            {
                UserScreen.DisplayMessage("\nPlease insert a deposit envelope containing");
                UserScreen.DisplayDollaramount(amount);
                UserScreen.DisplayMessageLine("in the deposit slot");
                bool envelopeReceived = depositSlot.isDepositEnvelopeReceived();
                if (envelopeReceived)
                {
                    UserScreen.DisplayMessageLine("Your envelope has been received");
                    Database.Credit(AccountNumber, amount);
                }

                else
                {
                    UserScreen.DisplayMessageLine("you did not insert an envelope ");
                }
            }

            else
            {
                UserScreen.DisplayMessageLine("jwıjdwjd");
            }
        }
Example #4
0
        public override void Execute()
        {
            decimal Balance      = Database.getAvailableBalance(AccountNumber);
            decimal TotalBalance = Database.getTotalBalance(AccountNumber);

            UserScreen.DisplayMessageLine("Information: ");
            UserScreen.DisplayMessage("Available Balance: ");
            UserScreen.DisplayDollaramount(Balance);
            UserScreen.DisplayMessage("Total Balance");
            UserScreen.DisplayDollaramount(TotalBalance);
            UserScreen.DisplayMessageLine(" ");
        }
Example #5
0
        public override void Execute()
        {
            //get available balance for the current user's Account
            decimal availableBalance = Database.GetAvailableBalance(AccountNumber);

            decimal totalBalance = Database.GetTotalBalance(AccountNumber);

            UserScreen.DisplayMessage("Balance Information:");
            UserScreen.appendMessage(" - Available balance: " + availableBalance);
            UserScreen.appendMessage(" - Total balance: " + totalBalance);
            UserScreen.appendMessage("");
        }
Example #6
0
    // display a menu of withdrawal amounts and the option to cancel;
    // return the chosen amount or 6 if the user chooses to cancel
    private int DisplayMenuOfAmounts()
    {
        int userChoice = 0; // variable to store return value

        // array of amounts to correspond to menu numbers
        int[] amounts = { 0, 20, 40, 60, 100, 200 };

        // loop while no valid choice has been made
        while (userChoice == 0)
        {
            // display the menu
            UserScreen.DisplayMessageLine("\nWithdrawal options:");
            UserScreen.DisplayMessageLine("1 - $20");
            UserScreen.DisplayMessageLine("2 - $40");
            UserScreen.DisplayMessageLine("3 - $60");
            UserScreen.DisplayMessageLine("4 - $100");
            UserScreen.DisplayMessageLine("5 - $200");
            UserScreen.DisplayMessageLine("6 - Cancel transaction");
            UserScreen.DisplayMessage(
                "\nChoose a withdrawal option (1-6): ");

            // get user input through keypad
            int input = keypad.GetInput();

            // determine how to proceed based on the input value
            switch (input)
            {
            // if the user chose a withdrawal amount (i.e., option
            // 1, 2, 3, 4, or 5), return the corresponding amount
            // from the amounts array
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                userChoice = amounts[input];  // save user's choice
                break;

            case CANCELED:             // the user chose to cancel
                userChoice = CANCELED; // save user's choice
                break;

            default:
                UserScreen.DisplayMessageLine(
                    "\nInvalid selection. Try again.");
                break;
            }
        }

        return(userChoice);
    }
Example #7
0
        public override void Execute()
        {
            BankDatabase bankDatabase = database;

            var AvailableBalance = bankDatabase.getAvailableBalance(AccountNumber);
            var TotalBalance     = bankDatabase.getTotalBalance(AccountNumber);

            UserScreen.DisplayMessageLine("\nBalance Information");
            UserScreen.DisplayMessage(" - Available Balance: ");
            UserScreen.DisplayDollarAmount(AvailableBalance);
            UserScreen.DisplayMessage("\n - Total Balance: ");
            UserScreen.DisplayDollarAmount(TotalBalance);
            UserScreen.DisplayMessageLine("");
        }
Example #8
0
    // prompt user to enter a deposit amount to credit
    private decimal PromptForDepositAmount()
    {
        // display the prompt and receive input
        UserScreen.DisplayMessage(
            "\nPlease input a deposit amount in CENTS (or 0 to cancel): ");
        int input = keypad.GetInput();

        // check whether the user canceled or entered a valid amount
        if (input == CANCELED)
        {
            return(CANCELED);
        }
        else
        {
            return(input / 100.00M);
        }
    }
Example #9
0
    // performs transaction; overrides Transaction's abstract method
    public override void Execute()
    {
        // get the available balance for the current user's Account
        decimal availableBalance =
            Database.GetAvailableBalance(AccountNumber);

        // get the total balance for the current user's Account
        decimal totalBalance = Database.GetTotalBalance(AccountNumber);

        // display the balance information on the screen
        UserScreen.DisplayMessageLine("\nBalance Information:");
        UserScreen.DisplayMessage(" - Available balance: ");
        UserScreen.DisplayDollarAmount(availableBalance);
        UserScreen.DisplayMessage("\n - Total balance: ");
        UserScreen.DisplayDollarAmount(totalBalance);
        UserScreen.DisplayMessageLine("");
    }
Example #10
0
        // yatirilacak parayi gir
        private decimal PromptForDepositAmount()
        {
            UserScreen.DisplayMessage(
                "\nEnter amount for deposit (or 0 to cancel): "
                );

            int input = keypad.GetInput();

            if (input == CANCELLED)
            {
                return(CANCELLED);
            }
            else
            {
                return(input);
            }
        }
Example #11
0
        private bool DisplayMenu()
        {
            UserScreen.Clear();
            UserScreen.DisplayMessageLine("\nWithdrawal menu\n");
            UserScreen.DisplayMessageLine("1->\t$10");
            UserScreen.DisplayMessageLine("2->\t$20");
            UserScreen.DisplayMessageLine("3->\t$50");
            UserScreen.DisplayMessageLine("4->\t$100");
            UserScreen.DisplayMessageLine("5->\t$200");
            UserScreen.DisplayMessageLine("6->\t$500");
            UserScreen.DisplayMessageLine("7->\t2000");
            UserScreen.DisplayMessageLine("8->\tOther");
            UserScreen.DisplayMessageLine("9->\tCancel transaction");
            UserScreen.DisplayMessage("\nChoose a with drawal amount: ");

            switch (keypad.GetInput())
            {
            case (int)Menu.AMOUNT10: return(IsWithrawal(10));

            case (int)Menu.AMOUNT20: return(IsWithrawal(20));

            case (int)Menu.AMOUNT50: return(IsWithrawal(50));

            case (int)Menu.AMOUNT100: return(IsWithrawal(100));

            case (int)Menu.AMOUNT200: return(IsWithrawal(200));

            case (int)Menu.AMOUNT500: return(IsWithrawal(500));

            case (int)Menu.AMOUNT2000: return(IsWithrawal(2000));

            case (int)Menu.OTHER:
                UserScreen.DisplayMessage("\nEnter a value: ");
                return(IsWithrawal(keypad.GetInput()));

            case (int)Menu.GO_BACK:
                return(false);

            default:
                UserScreen.DisplayMessageLine("\nInvalid selection! Try again.");
                break;
            }
            return(false);
        }
Example #12
0
    // perform transaction; overrides Transaction's abstract method
    public override void Execute()
    {
        amount = PromptForDepositAmount(); // get deposit amount from user

        // check whether user entered a deposit amount or canceled
        if (amount != CANCELED)
        {
            // request deposit envelope containing specified amount
            UserScreen.DisplayMessage(
                "\nPlease insert a deposit envelope containing ");
            UserScreen.DisplayDollarAmount(amount);
            UserScreen.DisplayMessageLine(" in the deposit slot.");

            // retrieve deposit envelope
            bool envelopeReceived = depositSlot.IsDepositEnvelopeReceived();

            // check whether deposit envelope was received
            if (envelopeReceived)
            {
                UserScreen.DisplayMessageLine(
                    "\nYour envelope has been received.\n" +
                    "The money just deposited will not be available " +
                    "until we \nverify the amount of any " +
                    "enclosed cash, and any enclosed checks clear.");

                // credit account to reflect the deposit
                Database.Credit(AccountNumber, amount);
            }
            else
            {
                UserScreen.DisplayMessageLine(
                    "\nYou did not insert an envelope, so the ATM has " +
                    "canceled your transaction.");
            }
        }
        else
        {
            UserScreen.DisplayMessageLine("\nCanceling transaction...");
        }
    }
Example #13
0
        public int displayMenu()
        {
            int Choice = 0;

            int[] amounts = { 0, 10, 20, 30, 40, 50, 100 };

            do
            {
                UserScreen.DisplayMessageLine("\nWithdrawal Menu:");
                UserScreen.DisplayMessageLine("1 - $10");
                UserScreen.DisplayMessageLine("2 - $20");
                UserScreen.DisplayMessageLine("3 - $30");
                UserScreen.DisplayMessageLine("4 - $40");
                UserScreen.DisplayMessageLine("5 - $50");
                UserScreen.DisplayMessageLine("6 - $100");
                UserScreen.DisplayMessageLine("7 - Custom");
                UserScreen.DisplayMessageLine("0 - Cancel");
                UserScreen.DisplayMessage("\nChoose a withdrawal amount: ");

                int input = keypad.GetInput();

                switch (input)
                {
                case 1:
                    Choice = amounts[input];
                    break;

                case 2:
                    Choice = amounts[input];
                    break;

                case 3:
                    Choice = amounts[input];
                    break;

                case 4:
                    Choice = amounts[input];
                    break;

                case 5:
                    Choice = amounts[input];
                    break;

                case 6:
                    Choice = amounts[input];
                    break;

                case 7:
                    UserScreen.DisplayMessage("\nPlease enter money you want: ");
                    Choice = keypad.GetInput();
                    break;

                case CANCELED:
                    Choice = CANCELED;
                    break;

                default:
                    UserScreen.DisplayMessageLine("\nInvalid selection. Try again.");
                    Choice = -1;
                    break;
                }
            } while (Choice < 0);
            return(Choice);
        }