示例#1
0
        /// <summary>
        /// Initiates interaction with user through text UI
        /// </summary>
        public void Interact(CarsHouse carsHouse)
        {
            Menu.FillInCarsList(carsHouse);

            CommandsHandler commandsHandler = new CommandsHandler(carsHouse);

            while (exitFlag != true)
            {
                commandsHandler.HandleCommand(Console.ReadLine());
            }
        }
 public CommandsHandler(CarsHouse carsHouse)
 {
     Storage            = carsHouse;
     CommandsDictionary = new Dictionary <string, ICommand>()
     {
         [Exit]                 = new ExitCommand(),
         [CountBrands]          = new CountBrandsCommand(Storage),
         [CountAll]             = new CountAllCommand(Storage),
         [AveragePrice]         = new AveragePriceCommand(Storage),
         [AveragePriceForBrand] = new AveragePriceForBrandCommand(Storage)
     };
 }
示例#3
0
        /// <summary>
        /// Allows user to fill in cars list in an instance of CarsHouse class,
        /// provides text UI for it
        /// </summary>
        private void FillInCarsList(CarsHouse carsHouse)
        {
            Console.WriteLine("Press any key to create a car and Esc to stop.");

            CarCreator carCreator = new CarCreator();

            while (Console.ReadKey(true).Key != ConsoleKey.Escape)
            {
                Car newCar = (Car)carCreator.Create();
                carsHouse.AddProduct(newCar);
                Console.WriteLine();
            }
        }
 private void TryToExecute(CarsHouse carsHouse, string command)
 {
 }