Ejemplo n.º 1
0
            public virtual void Use()
            {
                Console.WriteLine("What do you want to consume?");
                Inventory.MyInventory();
                string ConsumeItem = Convert.ToString(Console.ReadLine());

                if (FoodItems.ContainsKey(ConsumeItem))
                {
                    Console.WriteLine("You eat " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else if (DrinkItems.Equals(ConsumeItem))
                {
                    Console.WriteLine("You drink " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else if (SnackItems.Equals(ConsumeItem))
                {
                    Console.WriteLine("You snack on " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else
                {
                    Console.WriteLine("you don't have the item in your inventory.");
                }
                //Jämnför input med vad som finns i dictionaries. Stämmer det så ska den ge tillbaka en string beroende på vilken dictionary som ger "true". Ta bort saken från inventory.
            }
Ejemplo n.º 2
0
        public void OnPost()
        {
            EntreeItems = Menu.CategoryFilter(EntreeItems, Category);
            SideItems   = Menu.CategoryFilter(SideItems, Category);
            DrinkItems  = Menu.CategoryFilter(DrinkItems, Category);

            if (SearchItems != null)
            {
                EntreeItems = EntreeItems.Where(entree => entree.ToString().Contains(SearchItems, StringComparison.CurrentCultureIgnoreCase));
                SideItems   = SideItems.Where(side => side.ToString().Contains(SearchItems, StringComparison.CurrentCultureIgnoreCase));
                DrinkItems  = EntreeItems.Where(drink => drink.ToString().Contains(SearchItems, StringComparison.CurrentCultureIgnoreCase));
            }

            //prices area
            if (MinPrice != null && MinPrice != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Price >= MinPrice);
                SideItems   = SideItems.Where(item => item.Price >= MinPrice);
                DrinkItems  = DrinkItems.Where(item => item.Price >= MinPrice);
            }
            if (MaxPrice != null && MaxPrice != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Price <= MaxPrice);
                SideItems   = SideItems.Where(item => item.Price <= MaxPrice);
                DrinkItems  = DrinkItems.Where(item => item.Price <= MaxPrice);
            }
            if (MinPrice != null && MinPrice != 0 && MaxPrice != null && MaxPrice != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Price >= MinPrice && item.Price <= MaxPrice);
                SideItems   = SideItems.Where(item => item.Price >= MinPrice && item.Price <= MaxPrice);
                DrinkItems  = DrinkItems.Where(item => item.Price >= MinPrice && item.Price <= MaxPrice);
            }

            //Calories area
            if (MinCalories != null && MinCalories != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Calories >= MinCalories);
                SideItems   = SideItems.Where(item => item.Calories >= MinCalories);
                DrinkItems  = DrinkItems.Where(item => item.Calories >= MinCalories);
            }
            if (MaxCalories != null && MaxCalories != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Calories <= MaxCalories);
                SideItems   = SideItems.Where(item => item.Calories <= MaxCalories);
                DrinkItems  = DrinkItems.Where(item => item.Calories <= MaxCalories);
            }
            if (MinCalories != null && MinCalories != 0 && MaxCalories != null && MaxCalories != 0)
            {
                EntreeItems = EntreeItems.Where(item => item.Calories >= MinCalories && item.Calories <= MaxCalories);
                SideItems   = SideItems.Where(item => item.Calories >= MinCalories && item.Calories <= MaxCalories);
                DrinkItems  = DrinkItems.Where(item => item.Calories >= MinCalories && item.Calories <= MaxCalories);
            }
        }
Ejemplo n.º 3
0
            public virtual void Purchase()
            {
                Inventory ClassInv  = new Inventory();
                bool      isRunning = true;

                while (isRunning)
                {
                    Console.WriteLine("What do you want to purchase?");
                    ClassInv.ShowStock();
                    string PurchaseInput = Convert.ToString(Console.ReadLine());
                    if (FoodItems.ContainsKey(PurchaseInput) || DrinkItems.ContainsKey(PurchaseInput) || SnackItems.ContainsKey(PurchaseInput))
                    {
                        int price;
                        if (FoodItems.TryGetValue(PurchaseInput, out price) || DrinkItems.TryGetValue(PurchaseInput, out price) || SnackItems.TryGetValue(PurchaseInput, out price))
                        {
                            int CheckPrice = Convert.ToInt32(price);
                            if (MoneyPool.money >= CheckPrice)
                            {
                                Console.WriteLine("You add " + PurchaseInput + " to your items.");
                                Inventory.MyItems.Add(PurchaseInput);
                                MoneyPool.money -= CheckPrice;
                                Console.WriteLine("Your change is " + MoneyPool.money);
                                MoneyPool.money = 0;

                                Console.ReadKey();
                                Console.Clear();
                                isRunning = false;
                                //Om den hittar en som passar så ska den sparas i en lokal variabel så priset kan kollas och subtraheras ifrån vad användaren har.
                            }
                            else
                            {
                                Console.WriteLine("You don't have enough money to purchase that product.");
                                Console.ReadKey();
                            }
                        }
                        else
                        {
                            Console.WriteLine("Error, can't find value.");
                            Console.ReadKey();
                        }
                    }
                    else
                    {
                        Console.WriteLine("You entered the wrong product.");
                        Console.ReadKey();
                        Console.Clear();
                        isRunning = false;
                    }
                }
            }