예제 #1
0
        public static void Testing()
        {
            var desService = new DirectionService();

            desService.SetCurrentDestination(new DirectToBKK());
            DisplayDirection(desService);

            desService.SetCurrentDestination(new DirectToHKT());
            DisplayDirection(desService);

            var abusingState = new StopWatch();

            abusingState.SetCurrentState(new RunningState(abusingState));
            Console.WriteLine("StopWatch State: {0}", abusingState.GetCurrentState());

            abusingState.SetCurrentState(new StopState(abusingState));
            Console.WriteLine("StopWatch State: {0}", abusingState.GetCurrentState());

            abusingState.SetCurrentState(new RunningState(abusingState));
            Console.WriteLine("StopWatch State: {0}", abusingState.GetCurrentState());
        }