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"); }
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}"); }
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)); }
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! }