예제 #1
0
파일: Program.cs 프로젝트: umxyz/Zombie
        static void Main(string[] args)
        {
            TravelStrategy train   = new TrainStrategy();
            TravelContext  context = new TravelContext("广州", "上海");

            context.SetStrategy(train);
            context.TravelFuction();

            TravelStrategy air = new AirStrategy();

            context.SetStrategy(air);
            context.TravelFuction();

            TravelContext  context2 = new TravelContext2("广州", "上海", "最快");
            TravelStrategy walk     = new WalkfastStrategy();

            context2.SetStrategy(walk);
            context2.TravelFuction();
            Console.ReadKey();
        }
예제 #2
0
        public void Travel(TravelContext t)
        {
            TravelContext2 t2 = (TravelContext2)t;

            Console.WriteLine("从" + t2.Start + "到" + t2.End + t2.Way + "的步行方案");
        }
예제 #3
0
 public void Travel(TravelContext t)
 {
     Console.WriteLine("从" + t.Start + "到" + t.End + "的坐火车方案");
 }