Example #1
0
        private int[] GetIngredients()
        {
            bool       thatsAll    = false;
            List <int> ingredients = new List <int>();

            while (!thatsAll)
            {
                UserIO.PrintYellow("Add new ingredient? y/n");
                bool answer = UserIO.AskYesNoQ();

                if (answer)
                {
                    Console.Clear();
                    IngredientManager ingredientManager = new IngredientManager();
                    ingredientManager.ShowAllIngredients();
                    Console.WriteLine();
                    Console.WriteLine("Enter id of ingredient you want to add to your pizza");
                    int ingredientId = UserIO.GetUserInt(0, ingredientManager.GlobalIngredients.Count - 1);
                    ingredients.Add(ingredientId);
                    UserIO.PrintGreen($"{ingredientManager.GetOneIngredient(ingredientId)} was added as an ingredient");
                }
                else
                {
                    thatsAll = true;
                }
            }

            return(ingredients.ToArray());
        }
Example #2
0
        public void OrderIngredient()
        {
            Console.Clear();
            UserIO.PrintRed("Order Ingredient");
            Console.WriteLine();

            ShowAllIngredients();

            Console.WriteLine();
            Console.WriteLine("Select id of ingredient you want to order");
            int id = UserIO.GetUserInt(0, GlobalIngredients.Count - 1);

            Console.WriteLine();
            Console.WriteLine("Enter the amount (max 500)");
            int amount = UserIO.GetUserInt(0, 500);

            if (GlobalIngredients[id].Order(amount))
            {
                UserIO.PrintGreen($"You succesfully orderd {amount} pieces of {GlobalIngredients[id].Name} ");
                UpdateIngredients();
            }
            else
            {
                UserIO.PrintRed("Order failed");
            }
        }
Example #3
0
        private void ShowInvoice(Order order)
        {
            Console.Clear();
            UserIO.PrintRed($"Order nr:{order.Id}  -  placed on: {order.Date}");
            Console.WriteLine();

            string name      = "";
            string size      = "";
            string crust     = "";
            string quantity  = "";
            string itemPrice = "";

            Console.ForegroundColor = ConsoleColor.Yellow;
            UserIO.PrintPretty("Name", 15, "Size", 30, "Crust", 45, "Quantity", 60, "ItemPrice", true);
            Console.ResetColor();
            Console.WriteLine();

            for (int i = 0; i < order.ItemsArray.Length; i++)
            {
                int pizzaId = order.ItemsArray[i][0];
                name      = Convert.ToString(Pizza_Manager.GlobalPizzas[pizzaId].Name);
                size      = Convert.ToString((PizzaSize)order.ItemsArray[i][1]);
                crust     = Convert.ToString((PizzaCrust)order.ItemsArray[i][2]);
                quantity  = Convert.ToString(order.ItemsArray[i][3]);
                itemPrice = Convert.ToString(order.ItemPriceArray[i]);

                UserIO.PrintPretty(name, 15, size, 30, crust, 45, quantity, 60, itemPrice, true);
            }

            Console.WriteLine();
            UserIO.PrintYellow($"Total items: {order.ItemCount}");
            UserIO.PrintGreen($"Total price: {order.TotalPrice}");
            Console.WriteLine();
            UserIO.PrintDarkRed("Press enter to go back");
        }
Example #4
0
 public void CreateNewIngredient()
 {
     if (GetValidUserInput())
     {
         Ingredient ingredient = new Ingredient(Id, Name, Quantity);
         Id++;
         StoreIngredient(ingredient);
         SetGlobalIngredients();
         UserIO.PrintGreen("Ingredient succesfully added, press enter to continue...");
     }
     else
     {
         Console.WriteLine();
         UserIO.PrintRed("adding item failed, press enter to continue...");
     }
 }
Example #5
0
 public void CreateNewPizza()
 {
     Console.Clear();
     if (GetValidUserInput())
     {
         Pizza pizza = new Pizza(Id, Name, PriceSmall, PriceMedium, PriceLarge, Ingredients, IsVeg);
         Id++;
         StorePizza(pizza);
         SetGlobalPizzas();
         UserIO.PrintGreen("succesfully added pizza, press enter to continue");
     }
     else
     {
         Console.WriteLine("adding pizza failed, press enter to continue");
         Console.ReadLine();
     }
 }
Example #6
0
        public void MakeOrder()
        {
            PizzaManager pizzamanager = new PizzaManager();

            Pizza_Manager = pizzamanager;

            IngredientManager ingredientManager = new IngredientManager();

            Ingredient_Manager = ingredientManager;

            Order newOrder = new Order();
            bool  ordering = true;

            ItemIndex = 0;

            while (ordering)
            {
                Console.Clear();
                ShowCart(newOrder);
                GetUserInput(newOrder);
                SetOrder(newOrder);
                Console.Clear();
                ShowCart(newOrder);
                ItemIndex++;
                Console.WriteLine("Want some more? y/n");
                ordering = UserIO.AskYesNoQ();
            }
            //check if order can be made
            bool succes = CheckItemsAvailable(newOrder);

            if (!succes)
            {
                UserIO.PrintRed("---The order could not be made!---");
                Ingredient_Manager.SetGlobalIngredients();
                return;
            }
            Ingredient_Manager.UpdateIngredients();
            UserIO.PrintGreen("Order was made");
            //print factuur
            Console.ReadLine();
            ShowInvoice(newOrder);
            //store order
            StoreOrder(newOrder);
        }
Example #7
0
        public void ShowOnePizza(int id)
        {
            IngredientManager ingredientManager = new IngredientManager();

            UserIO.PrintRed($"{GlobalPizzas[id].Name}");
            Console.WriteLine();
            Console.WriteLine("Ingredients:");
            Console.WriteLine();
            for (int i = 0; i < GlobalPizzas[id].Ingredients.Length; i++)
            {
                int ingredientId = GlobalPizzas[id].Ingredients[i];
                Console.WriteLine($"  -{ingredientManager.GetOneIngredient(ingredientId)}");
            }

            Console.WriteLine();
            if (Convert.ToBoolean(GlobalPizzas[id].Veggy))
            {
                UserIO.PrintGreen("This is a vegetarian pizza");
            }
            UserIO.PrintYellow($"\nPriceSmall = {GlobalPizzas[id].PriceSmall} - PriceMedium = {GlobalPizzas[id].PriceMedium} - PriceLarge = {GlobalPizzas[id].PriceLarge}");
        }
Example #8
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();
        }