コード例 #1
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");
            }
        }
コード例 #2
0
    // perform transaction, overrides Transaction's abstract method
    public override void Execute()
    {
        bool cashDispensed = false; // cash was not dispensed yet

        // transaction was not canceled yet
        bool transactionCanceled = false;

        // loop until cash is dispensed or the user cancels
        do
        {
            // obtain the chosen withdrawal amount from the user
            int selection = DisplayMenuOfAmounts();

            // check whether user chose a withdrawal amount or canceled
            if (selection != CANCELED)
            {
                // set amount to the selected dollar amount
                amount = selection;

                // get available balance of account involved
                decimal availableBalance =
                    Database.GetAvailableBalance(AccountNumber);

                // check whether the user has enough money in the account
                if (amount <= availableBalance)
                {
                    // check whether the cash dispenser has enough money
                    if (cashDispenser.IsSufficientCashAvailable(amount))
                    {
                        // debit the account to reflect the withdrawal
                        Database.Debit(AccountNumber, amount);

                        cashDispenser.DispenseCash(amount); // dispense cash
                        cashDispensed = true;               // cash was dispensed

                        // instruct user to take cash
                        UserScreen.DisplayMessageLine(
                            "\nPlease take your cash from the cash dispenser.");
                    }
                    else // cash dispenser does not have enough cash
                    {
                        UserScreen.DisplayMessageLine(
                            "\nInsufficient cash available in the ATM." +
                            "\n\nPlease choose a smaller amount.");
                    }
                }
                else // not enough money available in user's account
                {
                    UserScreen.DisplayMessageLine(
                        "\nInsufficient cash available in your account." +
                        "\n\nPlease choose a smaller amount.");
                }
            }
            else
            {
                UserScreen.DisplayMessageLine("\nCanceling transaction...");
                transactionCanceled = true; // user canceled the transaction
            }
        } while ((!cashDispensed) && (!transactionCanceled));
    }
コード例 #3
0
ファイル: Withdrawal.cs プロジェクト: bkayranci/ATMStudyCase
        // 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);
        }
コード例 #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(" ");
        }
コード例 #5
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);
    }
コード例 #6
0
        private decimal PrompForDepositAmount()
        {
            UserScreen.DisplayMessageLine("\n please input a deposit amount in Cents");
            int input = keypad.GetInput();

            if (input == CANCELED)
            {
                return(CANCELED);
            }
            else
            {
                return(input);
            }
        }
コード例 #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("");
        }
コード例 #8
0
ファイル: BalanceInquiry.cs プロジェクト: damirpasa/CSharp6FP
    // 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("");
    }
コード例 #9
0
        public override void Execute()
        {
            amount = PromptForDepositAmount();

            if (amount != CANCELLED)
            {
                // tek seferde yatirilabilecek miktar
                bool envelopeReceived = depositSlot.IsDepositEnvelopeReceived(amount);

                if (envelopeReceived)
                {
                    UserScreen.DisplayMessageLine("\nAmount: " + amount);
                    UserScreen.DisplayMessageLine("\nPress for 1 to cancel. Press enter for continue.");

                    // yatirmak icin engel yok yatirmak icin onayla
                    if (keypad.GetInput(true) != 1)
                    {
                        Database.Credit(AccountNumber, amount);
                        UserScreen.DisplayMessageLine("\nDeposit operation success");
                        UserScreen.Sleep(4000);
                    }
                    else
                    {
                        UserScreen.DisplayMessageLine("\nOperation cancelled!");
                        UserScreen.Sleep(4000);
                    }
                }
                else
                {
                    UserScreen.DisplayMessageLine(
                        "\nSlot is not enough. Operation cancelled!"
                        );
                    UserScreen.Sleep(4000);
                }
            }
            else
            {
                UserScreen.DisplayMessageLine(
                    "\nCancelling operation..."
                    );
                UserScreen.Sleep(4000);
                UserScreen.Sleep(2000);
            }
        }
コード例 #10
0
ファイル: Withdrawal.cs プロジェクト: bkayranci/ATMStudyCase
        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);
        }
コード例 #11
0
ファイル: Withdrawal.cs プロジェクト: bkayranci/ATMStudyCase
        // islem yap
        public override void Execute()
        {
            BankDatabase bankDatabase = Database;
            Screen       screen       = UserScreen;

            bool isContinue = true;

            while (isContinue)
            {
                bool display = DisplayMenu();
                if (display == true)
                {
                    UserScreen.DisplayMessageLine("\nOperation success!");
                    isContinue = DoYouWantToContinue();
                }
                else if (display == false)
                {
                    isContinue = false;
                }
            }
        }
コード例 #12
0
ファイル: Deposit.cs プロジェクト: damirpasa/CSharp6FP
    // 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...");
        }
    }
コード例 #13
0
ファイル: Withdrawal.cs プロジェクト: bgoktugozdemir/CSharp
        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);
        }
コード例 #14
0
ファイル: Withdrawal.cs プロジェクト: bkayranci/ATMStudyCase
        // devam etmek istiyor musun
        private bool DoYouWantToContinue()
        {
            UserScreen.DisplayMessageLine("If you want to continue, press for 1.");

            return((keypad.GetInput(true) == 1) ? true : false);
        }