Exemplo n.º 1
0
        public void dispWithdraw()
        {
            Console.WriteLine("1> 10");
            Console.WriteLine("2> 50");
            Console.WriteLine("3> 500");

            int input = 1;// = Convert.ToInt32(Console.ReadLine());

            if (input > 0 && input < 4)
            {

                //opiton one is entered by the user
                if (input == 1)
                {

                    //attempt to decrement account by 10 punds
                    if (activeAccount.decrementBalance(10))
                    {
                        //if this is possible display new balance and await key press
                        Console.WriteLine("new balance " + activeAccount.getBalance());
                        Console.WriteLine(" (prese enter to continue)");
                        //Console.ReadLine();
                    }
                    else {
                        //if this is not possible inform user and await key press
                        Console.WriteLine("insufficent funds");
                        Console.WriteLine(" (prese enter to continue)");
                        //Console.ReadLine();
                    }
                }
                else if (input == 2)
                {
                    if (activeAccount.decrementBalance(50))
                    {
                        Console.WriteLine("new balance " + activeAccount.getBalance());
                        Console.WriteLine(" (prese enter to continue)");
                        //Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("insufficent funds");
                        Console.WriteLine(" (prese enter to continue)");
                        //Console.ReadLine();
                    }
                }
                else if (input == 3)
                {
                    if (activeAccount.decrementBalance(500))
                    {
                        Console.WriteLine("new balance " + activeAccount.getBalance());
                        Console.WriteLine(" (prese enter to continue)");
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("insufficent funds");
                        Console.WriteLine(" (prese enter to continue)");
                        Console.ReadLine();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void withdraw(int keyedValue)
        {
            int withdrawAmount = 0;

            if (keyedValue > 0 && keyedValue <= 5)
            {
                switch (keyedValue)
                {
                case 1:
                    withdrawAmount = 10;
                    break;

                case 2:
                    withdrawAmount = 20;
                    break;

                case 3:
                    withdrawAmount = 40;
                    break;

                case 4:
                    withdrawAmount = 100;
                    break;

                case 5:
                    withdrawAmount = 500;
                    break;

                default:
                    Console.WriteLine("Invalid selection. Please select a value from 1 - 3");
                    break;
                }

                if (withdrawAmount <= currentAccount.balance)
                {
                    // Withdraw from account
                    bool status = currentAccount.decrementBalance(withdrawAmount);
                    if (status)
                    {
                        Console.WriteLine("money withdrawn");
                        lblConsoleText.Text = " You have withdrawn the following funds : \n"
                                              + " £" + withdrawAmount + ".00 \n\n"
                                              + " Your balance is now : \n\n"
                                              + " £" + currentAccount.balance + ".00\n\n"
                                              + " Press enter to return to menu";
                    }
                    else
                    {
                        MessageBox.Show("Failed");
                    }
                }
                else
                {
                    // Insufficent funds
                    lblConsoleText.Text = "Sorry you have insufficent funds in your account\n\n"
                                          + " Please choose from the following Menu Items\n\n"
                                          + "  1> Withdraw       -  Remove funds from your account\n"
                                          + "  2> Balance         -  Display your current account balance\n"
                                          + "  3> Return Card   -  Exit the ATM system securly.";
                }
            }
            // Invalid Value entered
            else
            {
                lblConsoleText.Text += "\n\n Invalid selection. Please 'Enter' to return to menu";
                txtKeyed.Text        = "";
            }
        }