Пример #1
0
            public Menu CreateMenu(params string[] choices)
            {
                var menu = new NumericMenu();

                // Nackdel: upprepning av kod (foreach)
                foreach (var choice in choices)
                {
                    menu.Add(choice.Trim().ToUpper());
                }

                return(menu);
            }
Пример #2
0
        static void Main(string[] args)
        {
            Dictionary <int, Option> numericOptions = new Dictionary <int, Option>()
            {
                { 1, new Option(Actions.PrintAssa, "Print Assa") }, { 2, new Option(Actions.PrintName, "Print a Name") }, { 3, new Option(Actions.PrintNumbers, "Print Your Numbers") }
            };
            NumericMenu numMenu = new NumericMenu(numericOptions, "My test menu", "Please choose one of the following:", true);

            Dictionary <string, Option> stringOptions = new Dictionary <string, Option>()
            {
                { "Yuval", new Option(Actions.PrintYuval, "Print Yuval") }, { "Name", new Option(Actions.PrintName, "Print a Name") }, { "Numbers", new Option(Actions.PrintNumbers, "Print Your Numbers") }, { "NumMenu", new Option(numMenu.Run, "Show numeric menu") }
            };
            StringMenu strMenu = new StringMenu(stringOptions, "My test menu", "Please choose one of the following:", true);


            strMenu.Run();
        }
Пример #3
0
        static void Main(string[] args)
        {
            #region Supermarket objects

            var workers = new List <Worker> {
                new Worker("Avi"), new Worker("Eti"), new Worker("Mosh")
            };
            List <Cashier> cashiers = workers.Select(worker => new Cashier(worker)).ToList();
            var            products = new Dictionary <string, int> {
                { "Banana", 7 }, { "Bread", 10 }, { "Water", 8 }, { "Gums", 5 }
            };

            #endregion

            #region Services

            var lineService     = new LineService(new SupermarketLine <Customer>());
            var cashiersService = new CashiersService(cashiers, lineService, products);
            var workersService  = new WorkersService(workers, cashiersService);

            #endregion

            #region Management Menus

            var lineManagementMenu = new NumericMenu("Line Management Menu",
                                                     new List <IMenuOption>
            {
                new LineAdderOption(lineService),
                new LineMoverOption(lineService),
                new LineCustomersOption(lineService)
            });

            var cashiersManagementMenu = new NumericMenu("Cashiers Management Menu",
                                                         new List <IMenuOption>
            {
                new CashiersRegistersOption(cashiersService),
                new CashiersOpeningDateOption(cashiersService),
                new CashierIsolationOption(cashiersService)
            });

            var workersManagementMenu = new NumericMenu("Workers Management Menu",
                                                        new List <IMenuOption>
            {
                new WorkerCheckInOption(workersService),
                new WorkerCheckOutOption(workersService),
                new WorkersRegistersOption(workersService)
            });

            #endregion

            // The main menu that contains all the management menus
            var mainMenu = new NumericMenu("Main Menu", new List <IMenuOption>
            {
                lineManagementMenu, cashiersManagementMenu, workersManagementMenu
            });

            try
            {
                mainMenu.Action();
            }
            catch (Exception e)
            {
                System.Console.WriteLine($"MamaSuper process has failed! Failure message:\n{e.Message}");
            }
        }
Пример #4
0
        public string RenderNumericMenu()
        {
            var menu = new NumericMenu("  Banana   ", " Apple   ");

            return(menu.Render());
        }