Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Wired Brain Coffee Shop Info Tool");

            Console.WriteLine("Write 'help' to list available commands. \nWrite 'quit' to exit.");

            var coffeeShopDataProvider = new CoffeeShopDataProvider();

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

                if (string.Equals("quit", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                var coffeeShops = coffeeShopDataProvider.LoadCoffeeShops();

                var commandHandler =
                    (string.Equals("help", line, StringComparison.OrdinalIgnoreCase))
                    ? new HelpCommandHandler(coffeeShops) as ICommandHandler
                    : new CoffeeShopCommandHandler(coffeeShops, line);



                commandHandler.HandleCommand();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("WiredBrainCoffee - 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();

                if (string.Equals("quit1", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                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);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Wirded Brain Coffe - Shop Info Tool!");

            Console.WriteLine("Write help to list available coffe shop commands, write exit to quit the program");

            var coffeeShopDataProvider = new CoffeeShopDataProvider();

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

                if (string.Equals("quit", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                var coffeeShops = coffeeShopDataProvider.LoadCoffeShops();

                var commandHandler =
                    string.Equals("help", line, StringComparison.OrdinalIgnoreCase)
                                ?  new HelpCommandHandler(coffeeShops) as ICommandHandler
                                : new CoffeShopCommandHandler(coffeeShops, line);

                commandHandler.HandleCommand();
            }
        }
Exemple #4
0
#pragma warning disable IDE0060 // Remove unused parameter
        static void Main(string[] args)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            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();

                if (string.Equals("quit", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                var coffeeShops = coffeeShopDataProvider.LoadCoffeeShops();

                var commandHandler =
                    string.Equals("help", line, StringComparison.OrdinalIgnoreCase)
                    ? new HelpCommandHandler(coffeeShops) as ICommandHandler
                    : new  CoffeeShopCommandHandler(coffeeShops, line);

                commandHandler.HandleCommand();
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Write 'help' to list the coffee shops or 'quit' to leave the program! Then write the name of the location");

            var provider = new CoffeeShopDataProvider();

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

                if (string.Equals(line, "quit", StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }

                var coffeeShops = provider.LoadCoffeeShops();

                if (string.Equals(line, "help"))
                {
                    Console.WriteLine("> Available coffee shops");

                    foreach (var shop in coffeeShops)
                    {
                        Console.WriteLine($"> {shop.Location}");
                    }
                }
                else
                {
                    var availableShops = coffeeShops.Where(cs => cs.Location.ToLower().StartsWith(line.ToLower()));

                    var availableShopsCount = availableShops.Count();

                    if (availableShopsCount == 0)
                    {
                        Console.WriteLine($"> No coffee shops found for {line}");
                    }
                    else
                    {
                        if (availableShopsCount > 1)
                        {
                            Console.WriteLine($"> Multiple coffees shops available for the search criteria");

                            foreach (var availableShop in availableShops)
                            {
                                Console.WriteLine(availableShop.Location);
                            }
                        }
                        else
                        {
                            var availableShop = availableShops.Single();
                            Console.WriteLine($"> {availableShop.Location} - {availableShop.BeansInStockInKg}");
                        }
                    }
                }
            }
        }
        //adding from newbranch


        // change from master
        // second change from master
        static void Main(string[] args)
        {
            Console.WriteLine("Wired Brain Coffee - Shop Info Tool!");

            Console.WriteLine("remote änderung");


            var coffeeShopDataProvider = new CoffeeShopDataProvider();

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

                if (string.Equals("quit", line, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                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);
                    }
                }
                else
                {
                    var foundCoffeeShops = coffeeShops
                                           .Where(x => x.Location.StartsWith(line, StringComparison.OrdinalIgnoreCase))
                                           .ToList();

                    if (foundCoffeeShops.Count == 0)
                    {
                        Console.WriteLine($"> Command '{line}' not found");
                    }
                    else if (foundCoffeeShops.Count == 1)
                    {
                        var coffeeShop = foundCoffeeShops.Single();
                        Console.WriteLine($"> Location: {coffeeShop.Location}");
                        Console.WriteLine($"> Beans in stock: {coffeeShop.BeansInStockInKg} kg");
                    }
                    else
                    {
                        Console.WriteLine($"> Multiple matching coffee shop commands found:");
                        foreach (var coffeeType in foundCoffeeShops)
                        {
                            Console.WriteLine($"> {coffeeType.Location}");
                        }
                    }
                }
            }
        }