static void Main(string[] args)
        {
            Console.WriteLine("Wired Brain Coffee - Shop Info Tool!");
            Console.WriteLine("Write 'help' to list available commands");

            var coffeeShopDataProvider = new CoffeeShopDataProvider();



            while (true)
            {
                var line        = Console.ReadLine();
                var coffeeShops = coffeeShopDataProvider.LoadCoffeeShops();

                var commandHandler = // command handler can be HelpCommandHandler or CoffeeShopCommandHandler
                                     string.Equals("help", line, StringComparison.OrdinalIgnoreCase)
                    ? new HelpCommandHandler(coffeeShops) as ICommandHandler
                    : new CoffeeShopCommandHandler(coffeeShops, line);

                commandHandler.HandleCommand();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Wired Brain Coffee - Shop Info Tool!");
            Console.WriteLine("Write 'help' to list available coffee shop commands, " + "Write 'quit' to exit application");

            var coffeeShopDataProvider = new CoffeeShopDataProvider();

            while (true)
            {
                var line        = Console.ReadLine();
                var coffeeShops = coffeeShopDataProvider.LoadCoffeeShops();


                if (string.Equals("quit", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
                var commandHandler = string.Equals("help", line, StringComparison.OrdinalIgnoreCase)
                    ? new HelpCommandHandler(coffeeShops) as IHelpCommandHandler
                    : new CoffeeShopCommandHandler(coffeeShops, line);

                commandHandler.HandleCommand();


                //if (string.Equals("help", line, StringComparison.OrdinalIgnoreCase))
                //{
                //    commandHandler = new HelpCommandHandler(coffeeShops);
                //    commandHandler.HandleCommand();
                //}
                //else
                //{
                //    commandHandler = new CoffeeShopCommandHandler(coffeeShops, line);
                //    commandHandler.HandleCommand();
                //}
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Wired Brain Coffee - Shop Info Tool!");

            Console.WriteLine("Write 'help' to list available coffee shop comands");

            var coffeeShopDataProvider = new CoffeeShopDataProvider();

            while (true)
            {
                var line        = Console.ReadLine();
                var coffeeShops = coffeeShopDataProvider.LoadCoffeeShops();

                if (string.Equals("help", line, StringComparison.OrdinalIgnoreCase))
                {
                    Console.WriteLine("> Available coffee shop commands:");

                    foreach (var coffeeShop in coffeeShops)
                    {
                        Console.WriteLine($"> {coffeeShop.Location}");
                    }
                }
            }
        }