/// <summary>
 /// Creates Gum depending on Id of the gum and amount
 /// </summary>
 /// <param name="gumId"></param>
 /// <param name="rndNumber"></param>
 public void CreateGum(int gumId, int rndNumber)
 {
     for (int gumAdding = 0; gumAdding < rndNumber; gumAdding++)
     {
         Gum gum = new Gum(gumId);
         gumList.Add(gum);
     }
 }
Beispiel #2
0
        public void Addgum()
        {
            for (int i = 0; i < 14; i++)
            {
                Gum blueberry = new Gum("blåbær");
                blueber.Push(blueberry);
            }


            for (int i = 0; i < 7; i++)
            {
                Gum bromberry = new Gum("Brømbær");
                bromber.Push(bromberry);
            }

            for (int i = 0; i < 11; i++)
            {
                Gum trutti = new Gum("Trutti Frutti");
                fruttigum.Push(trutti);
            }

            for (int i = 0; i < 10; i++)
            {
                Gum orange = new Gum("Appelsin");
                appels.Push(orange);
            }

            for (int i = 0; i < 8; i++)
            {
                Gum strawberry = new Gum("Jordbær");
                jord.Push(strawberry);
            }

            for (int i = 0; i < 5; i++)
            {
                Gum apple = new Gum("Æble");
                apel.Push(apple);
            }
        }
        static void Menu(Dispenser dispenser, GumStorage gumStorage)
        {
            bool showmenu = true;

            while (showmenu)
            {
                Console.Clear();
                Console.WriteLine("================================");
                Console.WriteLine(" Welcome to this Gum Dispenser!");
                Console.WriteLine("================================");
                Console.WriteLine("(1) To turn the knob and draw a piece gum");
                Console.WriteLine("(2) Order new package of gum (if empty only)");
                Console.WriteLine("(3) Refill dispenser (if empty only)");
                Console.WriteLine("(4) Exit\n");
                Console.WriteLine("Gum left :" + dispenser.gums.Count);
                Console.WriteLine("Gum storage :" + gumStorage.gumStorage.Count);
                switch (UserKeyInput().Key)
                {
                case ConsoleKey.D1:
                    Console.Clear();
                    try
                    {
                        Gum tempgum = dispenser.DrawGum();
                        Console.WriteLine($"You have recieved a {tempgum.Flavour} flavoured gum!\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("There aren't any gum left!");
                    }
                    Console.WriteLine("Press 'Enter' to go back to the main menu!");
                    Console.ReadLine();
                    break;

                case ConsoleKey.D2:
                    if (gumStorage.gumStorage.Count == 0)
                    {
                        gumStorage.OrderGum();
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("You still have gum in storage, use that first!");
                        Console.WriteLine("Press 'Enter' to return to the menu");
                        Console.ReadLine();
                    }
                    break;

                case ConsoleKey.D3:
                    if (dispenser.gums.Count == 0)
                    {
                        try
                        {
                            FillDispenser();
                        }
                        catch (Exception)
                        {
                            Console.Clear();
                            Console.WriteLine("There's no gum in storage, please order more!");
                            Console.WriteLine("Press 'Enter' to go back to the menu!");
                            Console.ReadLine();
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("There are still gum left in the dispenser!");
                        Console.WriteLine("Press 'Enter' to return to the menu");
                        Console.ReadLine();
                    }
                    break;

                case ConsoleKey.D4:
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
        }