Beispiel #1
0
 static void HandleDeposit(Account anAccount)
 {
     Console.Write("Deposit amount: ");
     string request = Console.ReadLine();
     decimal deposit = Convert.ToDecimal(request);
     anAccount.Deposit(deposit);
 }
Beispiel #2
0
		static void Main(string[] args)
		{
            OverdraftProtection op = new OverdraftProtection(500);
            Account.DebitPolicy policy;
            policy = new Account.DebitPolicy(op.HandleDebit);
            Account myAccount = new Account(100, policy);

            bool done = false;
            do
            {
                DisplayMenu();
                string choice = Console.ReadLine();
                switch(choice.ToLower())
                {
                    case "w":
                        HandleWithdrawal(myAccount);
                        break;

                    case "d":
                        HandleDeposit(myAccount);
                        break;

                    case "q":
                        done = true;
                        break;

                    default:
                        InvalidChoice(choice);
                        break;
                }
                CurrentBalance(myAccount, op);
            }while(!done);
		}
Beispiel #3
0
		static void Main(string[] args)
		{
            Account myAccount = new Account(100);
            
            Account.OverdraftEventHandler handler = null;
            handler = new Account.OverdraftEventHandler(OnOverdraft);
            myAccount.AddOnOverdraft(handler);

            bool done = false;
            do
            {
                DisplayMenu();
                string choice = Console.ReadLine();
                switch(choice.ToLower())
                {
                    case "w":
                        HandleWithdrawal(myAccount);
                        break;

                    case "d":
                        HandleDeposit(myAccount);
                        break;

                    case "q":
                        done = true;
                        break;

                    default:
                        InvalidChoice(choice);
                        break;
                }
                CurrentBalance(myAccount);
            }while(!done);
		}
Beispiel #4
0
 static void HandleWithdrawal(Account anAccount)
 {
     Console.Write("Withdrawal amount: ");
     string request = Console.ReadLine();
     decimal withdrawal = Convert.ToDecimal(request);
     bool result = anAccount.Withdrawal(withdrawal);
     if(result == true)
         Console.WriteLine("Withdrawal of {0} was successful.", withdrawal);
     else
         Console.WriteLine("Withdrawal of {0} was not successful.", withdrawal);
 }
Beispiel #5
0
 static void CurrentBalance(Account anAccount, OverdraftProtection op)
 {
     Console.WriteLine("Balance is {0}", anAccount.Balance);
     Console.WriteLine("Available overdraft is {0}", op.AvailableLoan);
     Console.WriteLine("Current overdraft loan is {0}", op.CurrentLoan);
 }
Beispiel #6
0
 static void CurrentBalance(Account anAccount)
 {
     Console.WriteLine("Balance is {0}", anAccount.Balance);
 }