Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Initially ATM Machine in CardNotInsertedState
            ATMMachineContext atmMachine = new ATMMachineContext();

            Console.WriteLine("ATM Machine Current state : "
                              + atmMachine.CurrentATMState.GetType().Name);

            Console.WriteLine();
            atmMachine.EnterPin();
            atmMachine.WithdrawCash();
            atmMachine.EjectCard();
            atmMachine.InsertCard();

            Console.WriteLine();

            atmMachine.EnterPin();
            atmMachine.WithdrawCash();

            //Insert again when Machine has no cash
            atmMachine.InsertCard();
            atmMachine.EjectCard();

            Console.Read();
        }
Ejemplo n.º 2
0
 public CardNotInsertedState(ATMMachineContext context)
 {
     Context = context;
 }
Ejemplo n.º 3
0
 public NoCashState(ATMMachineContext context)
 {
     Context = context;
 }