public static void Main()
        {
            Appetizer almonds = new Almond();
            Appetizer cashew  = new Cashew();
            Appetizer peanuts = new Peanut();

            Drink whiskey = new Whiskey("Johny Walker", 50, cashew);

            Console.WriteLine("--------- Drink with cashew appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();

            whiskey.Appetizer = almonds;
            Console.WriteLine("--------- Drink with almonds appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();

            whiskey.Appetizer = peanuts;
            Console.WriteLine("--------- Drink with peanuts appetizer:");
            whiskey.DisplayInformation();
            Console.WriteLine();
        }
        public IceCreamBase Addon(int toppings, IceCreamBase icecream)
        {
            switch (toppings)
            {
            case (int)Toppings.Chocochips:
                icecream = new Chocochips(icecream);
                break;

            case (int)Toppings.Cookies:
                icecream = new Cookies(icecream);
                break;

            case (int)Toppings.Jelly:
                icecream = new Jelly(icecream);
                break;

            case (int)Toppings.Fruits:
                icecream = new Fruits(icecream);
                break;

            case (int)Toppings.Almonnd:
                icecream = new Almond(icecream);
                break;

            case (int)Toppings.Cashew:
                icecream = new Cashew(icecream);
                break;

            case (int)Toppings.Pistachio:
                icecream = new Pistachio(icecream);
                break;

            default:
                break;
            }

            return(icecream);
        }
示例#3
0
        public static void PrintOptions()
        {
            Console.WriteLine("What theme do you want for your gift basket?");
            Console.WriteLine("1. Fruit");
            Console.WriteLine("2. Nut");
            Console.WriteLine("3. Candy");



            string userInput = Console.ReadLine();

            if (userInput == "1")
            {
                Console.WriteLine("Preparing your fruit gift basket...");

                // To do: create a gift basket class and give it a list of fruit items

                // To do: create some instances of each item and add them to the gift basket.


                Console.WriteLine("All done! Press any key to exit.");
                Console.ReadKey();
            }
            else if (userInput == "2")
            {
                Console.WriteLine("Preparing your nut gift basket...");
                Almond newAlmond = new Almond()
                {
                    Salted             = true,
                    Name               = "Salted Almond",
                    DryRoasted         = false,
                    Shelled            = true,
                    TreeNut            = true,
                    CaloriesPerServing = 100,
                    ServingSize        = "100g",
                    isOrganic          = true
                };

                Cashew newCashew = new Cashew()
                {
                    Salted             = false,
                    Name               = "Whole Cashew",
                    DryRoasted         = false,
                    Shelled            = true,
                    TreeNut            = true,
                    CaloriesPerServing = 150,
                    ServingSize        = "100g",
                    isWhole            = true
                };

                GiftBasket nutGiftBasket = new GiftBasket()
                {
                    Name  = "Lots o' Nuts",
                    Price = 10.99,
                    GiftBasketInventory = new List <Food>()
                    {
                        newAlmond, newCashew
                    }
                };

                nutGiftBasket.GiftBasketInventory.ForEach(singleNut => Console.WriteLine(singleNut.Name));

                Console.WriteLine("All done! Press any key to continue.");
                Console.ReadKey();
            }
            else if (userInput == "3")
            {
                Console.WriteLine("Preparing your candy gift basket...");

                Console.WriteLine("All done! Press any key to exit.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Please enter either 1 or 2 to select an option."); Console.WriteLine("Press any key to continue.");
                Console.ReadKey();
            }
        }