public List <int> BuyItems()
        {
            do
            {
                Console.WriteLine("Enter the product code of the item you want to buy (Enter Done to complete your order.):");
                code = Console.ReadLine();
                if (int.TryParse(code, out id))
                {
                    Console.WriteLine("Enter the Quantity you would like to buy:");
                    if (int.TryParse(Console.ReadLine(), out quantity))
                    {
                        if (!StoreLogic.CheckQuantity(quantity))
                        {
                            for (int i = 0; i < quantity; i++)
                            {
                                numbers.Add(id);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Insufficient Stock of this item.");
                        }
                    }
                }
                else if (!code.ToLower().Equals("done"))
                {
                    Console.WriteLine("Invalid Product Code.");
                }
            } while (!code.ToLower().Equals("done"));

            return(numbers);
        }
示例#2
0
        public static double GetFoodPrice(int id)
        {
            double price = StoreLogic.GetItemPrice(foods.Cast <Product>().ToList(), id);

            return(IsFoodExipred(id) ? price / _isFoodExipredValue : price);
        }
 public SellingLogic()
 {
     storeLogic = new StoreLogic();
     payments   = new List <Payment>();
 }
 public static double GetDrinkPrice(int id)
 {
     return(StoreLogic.GetItemPrice(drinks.Cast <Product>().ToList(), id));
 }