コード例 #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();
        }
コード例 #2
0
 public CardNotInsertedState(ATMMachineContext context)
 {
     Context = context;
 }
コード例 #3
0
ファイル: NoCashState.cs プロジェクト: vipyadav/LearnWithVIP
 public NoCashState(ATMMachineContext context)
 {
     Context = context;
 }