Ejemplo n.º 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());
            }
        }
Ejemplo n.º 2
0
 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)
     };
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
0
 private void TryToExecute(CarsHouse carsHouse, string command)
 {
 }