示例#1
0
        public string AddFood(string type, string name, decimal price)
        {
            BakedFood food = null;

            if (type == "Bread")
            {
                food = new Bread(name, price);
            }
            else
            {
                food = new Cake(name, price);
            }

            bakedFoods.Add(food);
            return($"Added {name} ({type}) to the menu");
        }
示例#2
0
        public string OrderFood(int tableNumber, string foodName)
        {
            Table     table = tables.FirstOrDefault(x => x.TableNumber == tableNumber);
            BakedFood food  = bakedFoods.FirstOrDefault(x => x.Name == foodName);

            if (table == null)
            {
                return($"Could not find table {tableNumber}");
            }
            if (food == null)
            {
                return($"No {foodName} in the menu");
            }
            table.OrderFood(food);
            return($"Table {tableNumber} ordered {foodName}");
        }
示例#3
0
        public string AddFood(string type, string name, decimal price)
        {
            if (type != "Bread" && type != "Cake")
            {
                throw new ArgumentException();
            }

            BakedFood food = null;

            if (type == "Bread")
            {
                food = new Bread(name, price);
            }

            if (type == "Cake")
            {
                food = new Cake(name, price);
            }
            this.bakedFoods.Add(food);
            return(String.Format(OutputMessages.FoodAdded, name, food.GetType().Name));
        }
示例#4
0
        public string AddFood(string type, string name, decimal price)
        {
            BakedFood food = null;

            if (type == "Bread")
            {
                food = new Bread(name, price);
            }
            else if (type == "Cake")
            {
                food = new Cake(name, price);
            }



            if (food != null)
            {
                foods.Add(food);

                return($"Added {name} ({type}) to the menu");
            }

            return(null); // To be checked later!
        }