示例#1
0
        /// <summary>
        /// The product menu to show the 3 main alternatives (Drinks, Food, Snacks)
        /// </summary>
        public void Menu(
            InsertMoney Change, List <IProducts> Products, Drinks CocaCola, Drinks Pepsi, Drinks Fanta,
            Food Cheeseburger, Food HotDog, Food Pizza, Snacks Twix, Snacks ChocolateBalls, Snacks Mars)
        {
            AffordProducts afford     = new AffordProducts();
            int            totalMoney = 0;
            bool           stayAlive  = true;

            //foreach (int value in Change.money)
            //{
            //    totalMoney = totalMoney + value;
            //}
            while (stayAlive)
            {
                Program.DisplayMessage(
                    "There's currently 3 options per category. Please choose wisely\n" +
                    "D - Drinks\n" +
                    "F - Food\n" +
                    "S - Snacks\n" +
                    "\n" +
                    "X - Go back\n"
                    );

                char productsChoice = char.ToUpper(Console.ReadKey(true).KeyChar);

                List <IProducts> ProductsValidation = new List <IProducts>();

                switch (productsChoice)
                {
                case 'D':
                    ProductDrinks(totalMoney, Change, afford, Products, ProductsValidation, CocaCola, Pepsi, Fanta);
                    break;

                case 'F':
                    ProductFood(totalMoney, Change, afford, Products, ProductsValidation, Cheeseburger, HotDog, Pizza);
                    break;

                case 'S':
                    ProductSnacks(totalMoney, Change, afford, Products, ProductsValidation, Twix, ChocolateBalls, Mars);
                    break;

                case 'X':
                    stayAlive = false;
                    break;

                default:
                    Program.DisplayMessage("Please type one of the given values. (D, F, S, X)", ConsoleColor.Red);
                    break;
                }
                Console.Clear();
            }
        }
示例#2
0
        /// <summary>
        /// The product menu for snacks
        /// </summary>
        private void ProductSnacks(int totalMoney, InsertMoney Change, AffordProducts afford, List <IProducts> Products, List <IProducts> ProductsValidation,
                                   Snacks Twix, Snacks ChocolateBalls, Snacks Mars)
        {
            Console.Clear();

            Program.DisplayMessage("\nIt would seem you picked snacks! You must want a good snacky snack!", ConsoleColor.Green);
            bool stayAlive = true;

            foreach (int value in Change.money)
            {
                totalMoney = totalMoney + value;
            }

            while (stayAlive)
            {
                Program.DisplayMessage("\nHere's youll get a list of drinks that's currently available. Please pick one");
                Program.DisplayMessage("\n(You select a drink by writing the first letter of the product you want)\n", ConsoleColor.Yellow);

                Program.DisplayMessage(
                    $"You currently have {totalMoney} remaining to spend \nX - Go back. " +
                    $"\nZ - remaining change back.\n"
                    );

                foreach (IProducts item in Products)
                {
                    if (item is Snacks)
                    {
                        item.ProductsInfo();
                    }
                }
                char choiceDrinks = char.ToUpper(Console.ReadKey(true).KeyChar);


                switch (choiceDrinks)
                {
                case 'T':
                    ProductsValidation.Add(Twix);
                    totalMoney = afford.AffordProduct(totalMoney, ProductsValidation, Change);
                    break;

                case 'C':
                    ProductsValidation.Add(ChocolateBalls);
                    totalMoney = afford.AffordProduct(totalMoney, ProductsValidation, Change);
                    break;

                case 'M':
                    ProductsValidation.Add(Mars);
                    totalMoney = afford.AffordProduct(totalMoney, ProductsValidation, Change);
                    break;

                case 'X':
                    stayAlive = false;
                    break;

                case 'Z':
                    Console.Clear();
                    MoneyBack.MoneyBackCalculation(Change);
                    stayAlive = false;
                    break;

                default:
                    Program.DisplayMessage("Invalid keypress, please try again", ConsoleColor.Red);
                    break;
                }
                ProductsValidation.Clear();
                if (stayAlive == true)
                {
                    Console.ReadKey(true);
                }
                Console.Clear();
            }
        }
        /// <summary>
        /// Creates all the wares used in the vending machine.
        /// </summary>
        public void VendingMachinery(InsertMoney change)
        {
            Drinks CocaCola = new Drinks(
                "Coca Cola", 33, 12, "Cold beverage - perfect on warm summer days",
                "You crack open the cold Coca Cola", "sweet, bubbly taste of heaven"
                );

            Drinks Pepsi = new Drinks(
                "Pepsi", 33, 12, "Cold beverage - okay on warm summer days, inferior to Coca Cola",
                "You crack open the cold Pepsi", "sweet, bubbly taste of inferiority over Coca Cola"
                );

            Drinks Fanta = new Drinks(
                "Fanta", 33, 12, "Cold beverage - good on warm summer days, superior to Pepsi",
                "You crack open the cold Fanta", "sweet, bubbly taste of superior oranges");

            Food Cheeseburger = new Food(
                "Cheeseburger", 150, 29, "A filling burger - perfect if you ever feel hungry",
                "You unwrap the badboy", "filling taste of perfection"
                );

            Food Hotdog = new Food(
                "Hotdog", 90, 25, "A spicy hotdog - perfect for lunch",
                "You pour ketchup on it", "spicyness of the chili"
                );

            Food Pizza = new Food(
                "Hawaii pizza", 300, 85, "a heavenly pizza - perfect ANYTIME of the day",
                "You prepare your tastebuds", "godlike taste of an hawaiian pizza"
                );

            Snacks Twix = new Snacks(
                "Twix", 62, 10, "A biscuity snack - perfect to eat infront of the tv or computer",
                "You unwrap the paper", "wonderful caramel and chocolate melting together with the biscuit"
                );
            Snacks ChocolateBall = new Snacks(
                "Chocolate ball", 65, 11, "A chocolaty snack - filled with hopes and dreams",
                "You feel your mouth watering", "Chocolaty heaven in the form of a ball"
                );

            Snacks Mars = new Snacks(
                "Mars", 65, 10, "A Marsbar - for when you feel a little special",
                "You open the marsbar", "Chocolaty wonderfulness of the Mars"
                );

            ProductMenu productMenu = new ProductMenu();

            Products.Clear();

            Products.Add(CocaCola);
            Products.Add(Pepsi);
            Products.Add(Fanta);

            Products.Add(Cheeseburger);
            Products.Add(Hotdog);
            Products.Add(Pizza);

            Products.Add(Twix);
            Products.Add(ChocolateBall);
            Products.Add(Mars);

            productMenu.Menu(change, Products, CocaCola, Pepsi, Fanta, Cheeseburger, Hotdog, Pizza, Twix, ChocolateBall, Mars);
        }