コード例 #1
0
        static void Main(string[] args)
        {
            MenuItem food1 = new MenuItem("food1", 5.25, "description of first item", CategoryType.Appetizer);
            MenuItem food2 = new MenuItem("food2", 7.50, "description of second item", CategoryType.MainCourse);
            MenuItem food3 = new MenuItem("food3", 10, "description of third item", CategoryType.Dessert);

            Console.WriteLine("Print one menu item:");
            food1.PrintItem();

            Menu menu = new Menu();

            menu.AddItem(food1);
            menu.AddItem(food2);
            menu.AddItem(food3);

            Console.WriteLine("Print full menu:");
            menu.PrintMenu();

            Console.WriteLine("\nfood1 added on : " + food1.AddedOn);
            Console.WriteLine("food1 is new: " + food1.IsNew);
            Console.WriteLine("menu last updated: " + menu.LastUpdated.ToString());
            Console.WriteLine("new items available: " + menu.NewItemsAvailable + "\n");

            menu.RemoveItem(food1);
            menu.PrintMenu();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            MenuItem beeftacos    = new MenuItem("Tacos", 12.00);
            MenuItem chickentacos = new MenuItem("Tacos", 12.00);
            MenuItem chips        = new MenuItem("Chips and Pico", 4.50);

            beeftacos.Description    = "Ground beef tacos with cheese, lettuce, tomato and onion.";
            beeftacos.Category       = "Main Course";
            chickentacos.Description = "Grilled chicken tacos with cheese, lettuce, tomato and onion.";
            chickentacos.Category    = "Main Course";
            chickentacos.Created     = new DateTime(2015, 6, 3, 22, 15, 0);
            chips.Description        = "Corn tortilla chips with fresh pico de gallo.";
            chips.Category           = "Appetizer";
            Menu Cantina = new Menu("Cantina");

            Cantina.AddItem(beeftacos);
            Cantina.AddItem(chickentacos);
            Cantina.AddItem(chips);
            Cantina.RemoveItem(beeftacos);



            Console.WriteLine(Cantina.PrintMenu());
            Console.WriteLine(beeftacos.Equals(chickentacos));
            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // TEST data: name, description, price, category
            MenuItem testApp     = new MenuItem("Test Appetizer", "Test Appetizer Description", 8, CategoryType.Appetizer);
            MenuItem testEntree  = new MenuItem("Test Entree", "Test Entree Description", 16, CategoryType.MainCourse);
            MenuItem testDessert = new MenuItem("Test Dessert", "Test Dessert Description", 6, CategoryType.Dessert);


            Console.WriteLine("TEST: print the test items one at a time");
            Console.WriteLine(testApp.ItemName + ", " + testApp.ItemDescription + ", " + testApp.ItemPrice);
            Console.WriteLine(testEntree.ItemName + ", " + testEntree.ItemDescription + ", " + testEntree.ItemPrice);
            Console.WriteLine(testDessert.ItemName + ", " + testDessert.ItemDescription + ", " + testApp.ItemPrice);


            Console.WriteLine("TEST: adding the items to the menu");
            Menu testMenu = new Menu();

            testMenu.AddItem(testApp);
            testMenu.AddItem(testEntree);
            testMenu.AddItem(testDessert);


            Console.WriteLine("TEST: print the full menu with categories");
            testMenu.PrintMenu();

            Console.WriteLine("TEST: remove an item from the menu");
            testMenu.RemoveItem(testDessert);

            Console.WriteLine("TEST: reprint the full menu with categories, less the removed item");
            testMenu.PrintMenu();

            Console.WriteLine("TEST: print when the menu was last updated");
            Console.WriteLine(testMenu.LastUpdated.ToString());

            Console.WriteLine("TEST: print bool new items available");
            Console.WriteLine(testMenu.NewItemsAvailable);

            Console.WriteLine("TEST: print the appetizer added date");
            Console.WriteLine(testApp.AddedOn);

            Console.WriteLine("TEST: print bool appetizer is new");
            Console.WriteLine(testApp.IsNew);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            string option, password;
            Menu   menu = new Menu();

            //Add an item to the menu
            menu.AddItem("French Fries", MenuItem.Category.Appetizer, "deep fried potato stripes", 2.99);
            menu.AddItem("Chicken nuggets", MenuItem.Category.Appetizer, "deep fried meat", 4.99);

            //continue loop until user press ENTER
            do
            {
                Console.WriteLine("\nChoose option \n 1.View Menu \n 2.Add/Remove an item");
                option = Console.ReadLine();
                //display option
                if (option == "1")
                {
                    menu.Display();
                }//add and remove option
                else if (option == "2")
                {
                    //password protected
                    Console.WriteLine("Only Admin can add or remove an item. \nEnter password to Add or remove");
                    password = Console.ReadLine();
                    //password to Enter is "Password"
                    //password matches choose add/remove
                    if (password == "Password")
                    {
                        Console.WriteLine("1.Add\n2.Remove");
                        int adminOption = int.Parse(Console.ReadLine());
                        switch (adminOption)
                        {
                        //add enter the name description cost and category
                        case 1:
                            Console.WriteLine("\nEnter name of the item");
                            string addName = Console.ReadLine();
                            Console.WriteLine("\nAdd a description to the item");
                            string addDesc = Console.ReadLine();
                            Console.WriteLine("\nChoose item category \n 1.Appetizer \n 2.Main Course \n 3.Dessert");
                            string addCategory = Console.ReadLine();
                            Console.WriteLine("\nDecide price of the Item");
                            double addCost = double.Parse(Console.ReadLine());
                            //Adding according to the category
                            switch (addCategory)
                            {
                            case "1":
                                menu.AddItem(addName, MenuItem.Category.Appetizer, addDesc, addCost);
                                break;

                            case "2":
                                menu.AddItem(addName, MenuItem.Category.MainCourse, addDesc, addCost);
                                break;

                            case "3":
                                menu.AddItem(addName, MenuItem.Category.Dessert, addDesc, addCost);
                                break;
                            }
                            break;

                        //get name to remove item
                        case 2:
                            Console.WriteLine("\nEnter name of the item to remove");
                            string removeName = Console.ReadLine();
                            menu.RemoveItem(removeName);
                            break;
                        }
                    }
                }
            } while (option != "");
        }