コード例 #1
0
        private void GetUserInput(Order newOrder)
        {
            int[] item = new int[4];

            Pizza_Manager.ShowPizzaList();

            Console.WriteLine();
            Console.WriteLine("Select id to add to order");
            int id = UserIO.GetUserInt(0, Pizza_Manager.GlobalPizzas.Count - 1);

            item[0] = id;

            Console.Clear();
            ShowCart(newOrder);
            Pizza_Manager.ShowOnePizza(id);
            Console.WriteLine();
            UserIO.PrintBlue("---------------------------------------------------------------------");
            Console.WriteLine();

            Console.WriteLine("Select the size: Small = 1 | Medium = 2 | Large = 3");
            int size = UserIO.GetUserInt(1, 3);

            item[1] = size;

            Console.WriteLine("Select Crust: PanCrust = 1 | DeepCrust = 2 | CheeseCrust = 3");
            int crust = UserIO.GetUserInt(1, 3);

            item[2] = crust;

            Console.WriteLine("How many of these?");
            int quantity = UserIO.GetUserInt(1, 50);

            item[3] = quantity;

            newOrder.Items.Add(item);
            newOrder.ItemsArray = newOrder.Items.ToArray();
        }
コード例 #2
0
        private bool GetValidUserInput()
        {
            UserIO.PrintRed("Create new pizza");
            Console.WriteLine();
            Console.WriteLine("Enter name");
            string name = UserIO.GetUserString();

            if (CheckIfInList(name))
            {
                Console.WriteLine("Pizza already exists");
                return(false);
            }

            Console.WriteLine("Enter price for a small pizza");
            double priceSmall = UserIO.GetUserDouble(0, 1000);

            Console.WriteLine("Enter price for a medium pizza");
            double priceMedium = UserIO.GetUserDouble(0, 1000);

            Console.WriteLine("Enter price for a large pizza");
            double priceLarge = UserIO.GetUserDouble(0, 1000);

            Console.WriteLine("choose ingredients");
            int[] ingredients = GetIngredients();

            Console.WriteLine("Is this a vegetarian pizza? y/n");
            bool isVeg = UserIO.AskYesNoQ();

            Name        = name;
            PriceSmall  = priceSmall;
            PriceMedium = priceMedium;
            PriceLarge  = priceLarge;
            Ingredients = ingredients;
            IsVeg       = isVeg;
            return(true);
        }
コード例 #3
0
        private void ShowBalanceForDay(int day)
        {
            //Loop true all orders and add the prices. fill 2 lists: one with all used ingredients (id),
            //the other with times they where used (quantity * size) 1=small 2=med 3=large
            double     earningsDay     = 0;
            int        itemsDay        = 0;
            List <int> ingredientId    = new List <int>();
            List <int> ingredientCount = new List <int>();

            foreach (var order in SortedByDay[day])
            {
                earningsDay += order.TotalPrice;
                itemsDay    += order.ItemCount;

                for (int i = 0; i < order.ItemsArray.Length; i++)
                {
                    int pizzaId       = order.ItemsArray[i][0];
                    int pizzaSize     = order.ItemsArray[i][1];
                    int pizzaQuantity = order.ItemsArray[i][3];
                    //Console.WriteLine(pizzaId);

                    int[] pizzaIngr = Pizza_Manager.GlobalPizzas[pizzaId].Ingredients;

                    //loop over pizza ingredients
                    for (int j = 0; j < pizzaIngr.Length; j++)
                    {
                        //if id is not in list, ad to list, else add count to existing
                        if (!ingredientId.Contains(pizzaIngr[j]))
                        {
                            ingredientId.Add(pizzaIngr[j]);
                            ingredientCount.Add(pizzaSize * pizzaQuantity);
                        }
                        else
                        {
                            int index = ingredientId.IndexOf(pizzaIngr[j]);
                            ingredientCount[index] += pizzaSize * pizzaQuantity;
                        }
                    }
                }
            }
            IngredientManager ingredientManager = new IngredientManager();

            Ingredient_Manager = ingredientManager;

            //Display obtained info

            Console.Clear();
            UserIO.PrintRed($"Balance for Day {SortedByDay[day][0].Date.ToString("d")}");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            UserIO.PrintPretty("Ingredient used", 20, "Times used");
            Console.WriteLine();
            Console.ResetColor();

            for (int i = 0; i < ingredientId.Count; i++)
            {
                UserIO.PrintPretty($"{ Ingredient_Manager.GetOneIngredient(ingredientId[i]) }", 20, $"{ ingredientCount[i] }");
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"Total Items sold: {itemsDay}");
            UserIO.PrintGreen($"Total income: {earningsDay} EUR");
            Console.WriteLine();

            UserIO.PrintDarkRed("Press enter to go back");

            Console.ReadLine();
        }