示例#1
0
        private static void CareControl(AutoShow autoShow, Invoker receiver)
        {
            while (true)
            {
                Console.WriteLine("What does car do?");
                string command = Console.ReadLine();
                switch (command)
                {
                case "average price":
                {
                    try
                    {
                        receiver.Command = new AveragePrice(autoShow);
                        receiver.RunCommands();
                    }
                    catch (NoSuchAnElementException exception)
                    {
                        Console.WriteLine(exception.Message);
                    }
                }
                    ; break;

                case "average price type":
                {
                    try
                    {
                        receiver.Command = new AveragePriceType(autoShow, "BMW");
                        receiver.RunCommands();
                    }
                    catch (NoSuchAnElementException exception)
                    {
                        Console.WriteLine(exception.Message);
                    }
                }
                    ; break;

                case "count all":
                {
                    receiver.Command = new CountAll(autoShow);
                    receiver.RunCommands();
                }
                    ; break;

                case "count types":
                {
                    receiver.Command = new CountTypes(autoShow);
                    receiver.RunCommands();
                }
                    ; break;

                case "exit":
                {
                    receiver.Command = new Exit(autoShow);
                    receiver.RunCommands();
                }
                    ; break;
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Invoker    invoker  = new Invoker();
            List <Car> cars     = InitialCarList();
            AutoShow   autoShow = new AutoShow(cars);

            CareControl(autoShow, invoker);
        }
示例#3
0
 /// <summary>
 /// This is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 public CountAll(AutoShow autoShow) : base(autoShow)
 {
 }
示例#4
0
 /// <summary>
 /// This method cancels of the method count all
 /// </summary>
 public override void Undo()
 {
     AutoShow.CountAll();
 }
示例#5
0
 /// <summary>
 /// This is method prints the result of the method count all
 /// </summary>
 public override void Excecute()
 {
     PrintResult(AutoShow.CountAll());
 }
示例#6
0
 /// <summary>
 /// This methods cancels of the method average price
 /// </summary>
 public override void Undo()
 {
     AutoShow.AveragePrice();
 }
示例#7
0
 /// <summary>
 /// This method prints the result of the method average price
 /// </summary>
 public override void Excecute()
 {
     PrintResult(AutoShow.AveragePrice());
 }
示例#8
0
 /// <summary>
 /// This is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 public AveragePrice(AutoShow autoShow) : base(autoShow)
 {
 }
示例#9
0
 /// <summary>
 /// This method cancels of the method average price type
 /// </summary>
 public override void Undo()
 {
     AutoShow.AveragePriceType(Marka);
 }
示例#10
0
 /// <summary>
 /// This is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 /// <param name="marka"></param>
 public AveragePriceType(AutoShow autoShow, string marka) : base(autoShow)
 {
     this.Marka = marka;
 }
示例#11
0
 /// <summary>
 /// This method excecutes of the method exit
 /// </summary>
 public override void Excecute()
 {
     AutoShow.Exit();
 }
示例#12
0
 /// <summary>
 /// Thsi is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 public Exit(AutoShow autoShow) : base(autoShow)
 {
 }
示例#13
0
 /// <summary>
 /// This is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 public Command(AutoShow autoShow)
 {
     AutoShow = autoShow;
 }
示例#14
0
 public override void Undo()
 {
     AutoShow.CountTypes();
 }
示例#15
0
 /// <summary>
 /// This is constructor class
 /// </summary>
 /// <param name="autoShow"></param>
 public CountTypes(AutoShow autoShow) : base(autoShow)
 {
 }