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; } } }
static void Main(string[] args) { Invoker invoker = new Invoker(); List <Car> cars = InitialCarList(); AutoShow autoShow = new AutoShow(cars); CareControl(autoShow, invoker); }
/// <summary> /// This is constructor class /// </summary> /// <param name="autoShow"></param> public CountAll(AutoShow autoShow) : base(autoShow) { }
/// <summary> /// This method cancels of the method count all /// </summary> public override void Undo() { AutoShow.CountAll(); }
/// <summary> /// This is method prints the result of the method count all /// </summary> public override void Excecute() { PrintResult(AutoShow.CountAll()); }
/// <summary> /// This methods cancels of the method average price /// </summary> public override void Undo() { AutoShow.AveragePrice(); }
/// <summary> /// This method prints the result of the method average price /// </summary> public override void Excecute() { PrintResult(AutoShow.AveragePrice()); }
/// <summary> /// This is constructor class /// </summary> /// <param name="autoShow"></param> public AveragePrice(AutoShow autoShow) : base(autoShow) { }
/// <summary> /// This method cancels of the method average price type /// </summary> public override void Undo() { AutoShow.AveragePriceType(Marka); }
/// <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; }
/// <summary> /// This method excecutes of the method exit /// </summary> public override void Excecute() { AutoShow.Exit(); }
/// <summary> /// Thsi is constructor class /// </summary> /// <param name="autoShow"></param> public Exit(AutoShow autoShow) : base(autoShow) { }
/// <summary> /// This is constructor class /// </summary> /// <param name="autoShow"></param> public Command(AutoShow autoShow) { AutoShow = autoShow; }
public override void Undo() { AutoShow.CountTypes(); }
/// <summary> /// This is constructor class /// </summary> /// <param name="autoShow"></param> public CountTypes(AutoShow autoShow) : base(autoShow) { }