Ejemplo n.º 1
0
        /// <summary>
        /// The main.
        /// </summary>
        private static void Main()
        {
            Console.WriteLine("User name: {0}", UserName);
            Console.WriteLine("Password:  {0}", Password);
            GMRequester.InitRequester(UserName, Password);
            var menus = GMRequester.LoadGrillMenus();
            var grill = new Grill();
            LoadMenusAndPrintThem(menus);

            bool requestadToExit;
            do
            {
                var menuToPrepare = ChooseGrillMenu(menus); // Choose menu.
                var menuItems = GetAllMenuItems(menuToPrepare).ToList(); // Get all menu items.

                PrepareMenu(grill, menuItems); // Prepare menu.
                grill.ClearMenuItemsOnGrill();

                requestadToExit = RequestToExit();  // Ask to exit.

                if (!requestadToExit)
                {
                    PrintMenus(menus);
                }

            } while (!requestadToExit);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Prepare one menu.
        /// </summary>
        /// <param name="grill"></param>
        /// <param name="menuItems"></param>
        private static void PrepareMenu(Grill grill, List<GrillMenuItem> menuItems)
        {
            var totalPrepareTime = TimeSpan.Zero;
            do
            {
                TimeSpan prepareTime;
                PrintNextStepInfo();
                var addedOnGrillItemsCount = grill.FillGrillItems(menuItems).Count(); // Fill items on grill.
                Console.WriteLine("Added {0} from {1}", addedOnGrillItemsCount, menuItems.Count);

                grill.PrintGrill(); // Print grill in console.

                grill.GetNextPreparedItems(out prepareTime); // Do next prepare iteration.
                totalPrepareTime += prepareTime; // Sum all prepare time.
                var preparedItemsCount = menuItems.RemoveAll(i => i.IsPrepared); // Remove prepared items from main collection.

                grill.ClearMenuItemsOnGrill(); // Clear grill items for next iteration.
                Console.WriteLine("Prepared items {0} from {1}. Prepare time: {2}", preparedItemsCount, addedOnGrillItemsCount, prepareTime);

            } while (menuItems.Any());

            PrintFinishInfo(totalPrepareTime);
        }