Beispiel #1
0
 void Start()
 {
     milkss = GameObject.Find("GameManager").GetComponent <milk>();
 }
        static void Main(string[] args)
        {
            int    fatContent  = 0;
            int    packageSize = 0;
            string input;
            bool   correctInput = true;

            do
            {
                string   menuHeader  = "Välkommen till MULTIFABRIKEN";
                string[] menuContent = new string[] { "Lägg till en vara", "Lista varor", "Avsluta" };

                var menu = new Menu(menuContent);
                menu = menu.GetMenu(menu, menuHeader); // Skriver ut vår meny för användaren

                switch (menu.SelectedIndex)
                {
                case 0:
                    // Lägg till vara
                    menuHeader  = "Lägg till en vara";
                    menuContent = new string[] { "Havremjölk", "Godis", "Bil", "Rör", "Avsluta" };
                    menu        = new Menu(menuContent);
                    menu        = menu.GetMenu(menu, menuHeader);

                    switch (menu.SelectedIndex)
                    {
                    case 0:
                        Console.Clear();
                        // Mjölk
                        while (fatContent < 2 || fatContent > 11)
                        {
                            Console.WriteLine("Vilken fettprocent? Minst 2%, max 11%");
                            input      = Console.ReadLine();
                            fatContent = Convert.ToInt32(input);
                            if (fatContent < 2 || fatContent > 11)
                            {
                                Console.WriteLine("Minst 2% och max 11% fett.");
                            }
                        }
                        Console.WriteLine("");
                        while (packageSize < 1 || packageSize > 3)
                        {
                            Console.WriteLine("Vilken förpackning vill du ha?");
                            for (int i = 0; i < products.packageList.Count; i++)
                            {
                                Console.WriteLine("[{0}] {1}", i + 1, products.packageList[i]);
                            }
                            input = Console.ReadLine();

                            packageSize = Convert.ToInt32(input);
                            if (packageSize < 1 || packageSize > 3)
                            {
                                Console.WriteLine("Ogiltligt val, välj med knapparna 1-3");
                            }
                        }

                        packageSize--;
                        milk milk = new milk(fatContent, packageSize);

                        order.orderList.Add(milk);
                        Products.products.antal++;

                        break;

                    case 1:
                        // Godis
                        Console.Clear();

                        Console.WriteLine("Vilken godissort vill du ha?");
                        for (int i = 0; i < products.godisLista.Count; i++)
                        {
                            Console.WriteLine("[{0}] {1}", i + 1, products.godisLista[i]);
                        }

                        input = Console.ReadLine();
                        int SelectedIndex = Convert.ToInt32(input);
                        SelectedIndex--;

                        Console.WriteLine("Hur många kg {0} vill du ha?", order.godisLista[SelectedIndex]);
                        input = Console.ReadLine();
                        int candyAmount = Convert.ToInt32(input);

                        candy candy = new candy(SelectedIndex, candyAmount);

                        order.orderList.Add(candy);
                        Products.products.antal++;

                        break;

                    case 2:
                        // Bil
                        Console.Clear();

                        Console.WriteLine("Vilken modell vill du ha?");
                        for (int i = 0; i < products.bilLista.Count; i++)
                        {
                            Console.WriteLine("[{0}] {1}", i + 1, products.bilLista[i]);
                        }
                        input = Console.ReadLine();
                        int selectedIndex = Convert.ToInt32(input);
                        selectedIndex--;

                        Console.WriteLine("Vilken färg vill du ha på bilen?");
                        string carColour = Console.ReadLine();

                        //------------------------From Stackoverflow------------------------//
                        char[] a = carColour.ToCharArray();
                        a[0]      = char.ToUpper(a[0]);
                        carColour = new string(a);
                        //------------------------------------------------------------------//
                        while (correctInput == true)
                        {
                            Console.WriteLine("Vill du ha de sniceiga lyxpaketet?");
                            Console.WriteLine("[J/N]");
                            input = Console.ReadLine();
                            char[] b = input.ToCharArray();
                            b[0]  = char.ToUpper(b[0]);
                            input = new string(b);
                            bool lux = false;

                            if (input[0] == 'J')
                            {
                                lux          = true;
                                correctInput = false;
                            }
                            else if (input[0] == 'N')
                            {
                                Console.WriteLine("Du valde fel! Du får betala lyxpaket ändå!");
                                Console.ReadKey();
                                lux          = true;
                                correctInput = false;
                            }
                            else
                            {
                                Console.WriteLine("Fel inmatning! [J] eller [N]!");
                            }
                            cars cars = new cars(selectedIndex, carColour, lux);

                            order.orderList.Add(cars);
                            Products.products.antal++;
                        }
                        break;

                    case 3:
                        // Rör

                        Console.Clear();
                        Console.WriteLine("Vilket material vill du ha?");
                        for (int i = 0; i < products.myPipes.Count; i++)
                        {
                            Console.WriteLine("[{0}] {1}", i + 1, products.myPipes[i]);
                        }

                        input         = Console.ReadLine();
                        selectedIndex = Convert.ToInt32(input);
                        selectedIndex--;

                        Console.WriteLine("Vilken längd i millimeter vill du ha?");
                        input = Console.ReadLine();
                        int selectedLength = Convert.ToInt32(input);


                        Console.WriteLine("Vilken diameter i millimeter  vill du ha?");
                        input = Console.ReadLine();
                        int selectedDiameter = Convert.ToInt32(input);

                        pipes pipes = new pipes(selectedLength, selectedDiameter, selectedIndex);


                        order.orderList.Add(pipes);
                        Products.products.antal++;
                        break;
                    }

                    break;


                case 1:
                    // Lista varor
                    Console.Clear();
                    Console.WriteLine("Du har beställt {0} st produkter", order.antal);
                    Console.WriteLine();
                    SortThroughList();
                    PrintItemsInList();
                    Console.ReadKey();

                    break;


                case 2:
                    // Avsluta
                    SortThroughList();
                    PrintItemsInList();
                    return;
                }
            } while (true);
        }