Example #1
0
        //public IReadOnlyCollection<IBakedFood> TotalOrderedFoods => this.totalOrderedFoods.ToList().AsReadOnly();
        //public IReadOnlyCollection<IDrink> TotalOrderedDrinks => this.totalOrderedDrinks.ToList().AsReadOnly();

        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood newFood = CheckIFFoodExistsAndCreateIt(type, name, price);

            this.bakedFoods.Add(newFood);
            return(string.Format(OutputMessages.FoodAdded, name, type));
        }
Example #2
0
 public void OrderFood(IBakedFood food)
 {
     if (IsReserved == true)
     {
         foodOrders.Add(food);
     }
 }
Example #3
0
 public void OrderFood(IBakedFood food)
 {
     if (food != null)
     {
         this.FoodOrders.Add(food);
     }
 }
Example #4
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = foodFactory.CreateFood(type, name, price);

            bakedFoods.Add(food);
            return($"Added {food.Name} ({food.GetType().Name}) to the menu");
        }
Example #5
0
        private IBakedFood GetFood(string name)
        {
            IBakedFood bakedFood = bakedFoods
                                   .FirstOrDefault
                                       (f => f.Name == name);

            return(bakedFood);
        }
Example #6
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = this.foodFactory.CreateFood(type, name, price);

            this.bakedFoods.Add(food);

            return(string.Format(OutputMessages.FoodAdded, name, type));
        }
Example #7
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

            if (type == "Bread")
            {
                food = new Bread(name, price);
            }
            else if (type == "Cake")
            {
                food = new Cake(name, price);
            }
            bakedFoods.Add(food);
            return($"Added {name} ({type}) to the menu");
        }
Example #8
0
        public string AddFood(string type, string name, decimal price)
        {
            if (type == "Bread")
            {
                food = new Bread(name, price);
            }
            else if (type == "Cake")
            {
                food = new Cake(name, price);
            }

            bakedFoods.Add(food);

            return(string.Format(OutputMessages.FoodAdded, name, type));
        }
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = type switch
            {
                "Bread" => new Bread(name, price),
                "Cake" => new Cake(name, price),
                _ => null
            };

            this.bakedFoods.Add(food);

            var outputMessage = string.Format(OutputMessages.FoodAdded, name, type);

            return(outputMessage);
        }
Example #10
0
        private IBakedFood CreateBakedFood(BakedFoodType bakedFoodType, string name, decimal price)
        {
            IBakedFood food = null;

            switch (bakedFoodType)
            {
            case BakedFoodType.Bread:
                food = new Bread(name, price);
                break;

            case BakedFoodType.Cake:
                food = new Cake(name, price);
                break;
            }
            return(food);
        }
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

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

            this.bakedFoods.Add(food);
            return($"Added {name} ({type}) to the menu");
        }
Example #12
0
        private IBakedFood CreateFood(string foodType,
                                      string name, decimal price)
        {
            IBakedFood bakedFood = null;

            if (foodType == BakedFoodType.Bread.ToString())
            {
                bakedFood = new Bread(name, price);
            }
            if (foodType == BakedFoodType.Cake.ToString())
            {
                bakedFood = new Cake(name, price);
            }

            return(bakedFood);
        }
Example #13
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable     table = this.tables.FirstOrDefault(x => x.TableNumber == tableNumber);
            IBakedFood food  = this.bakedFoods.FirstOrDefault(x => x.Name == foodName);

            if (table == null)
            {
                return($"Could not find table {tableNumber}");
            }
            else if (food == null)
            {
                return($"No {foodName} in the menu");
            }
            table.OrderFood(food);
            return($"Table {table.TableNumber} ordered {food.Name}");
        }
Example #14
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

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

            bakedFoods.Add(food);
            return(string.Format(OutputMessages.FoodAdded, food.Name, food.GetType().Name));
        }
Example #15
0
        private static IBakedFood CheckIFFoodExistsAndCreateIt(string type, string name, decimal price)
        {
            Enum.TryParse(type, out BakedFoodType foodType);
            IBakedFood currentFood = null;

            switch (foodType)
            {
            case BakedFoodType.Bread:
                currentFood = new Bread(name, price);
                break;

            case BakedFoodType.Cake:
                currentFood = new Cake(name, price);
                break;
            }
            return(currentFood);
        }
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

            switch (type)
            {
            case "Cake": food = new Cake(name, price); break;

            case "Bread": food = new Bread(name, price); break;

            default:
                break;
            }
            this.bakedFoods.Add(food);

            return(string.Format(OutputMessages.FoodAdded, name, type));
        }
Example #17
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable table = this.tables.FirstOrDefault(t => t.TableNumber == tableNumber);

            if (table == null)
            {
                return(String.Format(OutputMessages.WrongTableNumber, tableNumber));
            }
            IBakedFood food = this.bakedFoods.FirstOrDefault(f => f.Name == foodName);

            if (food == null)
            {
                return(String.Format(OutputMessages.NonExistentFood, foodName));
            }
            table.OrderFood(food);
            return(String.Format(OutputMessages.FoodOrderSuccessful, tableNumber, foodName));
        }
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

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

            bakedFoods.Add(food);

            return($"Added {food.Name} ({food.GetType().Name}) to the menu");
        }
Example #19
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

            switch (type)
            {
            case "Bread":
                food = new Bread(name, price);
                break;

            case "Cake":
                food = new Cake(name, price);
                break;
            }

            foodList.Add(food);                                               //TODO: idk
            return($"Added {food.Name} ({food.GetType().Name}) to the menu"); //TODO: if??
        }
Example #20
0
        public string AddFood(string type,
                              string name, decimal price)
        {
            IBakedFood bakedFood
                = CreateFood(type, name, price);

            if (bakedFood == null)
            {
                return(null);
            }

            bakedFoods.Add(bakedFood);

            string msg = $"Added {name} " +
                         $"({type}) to the menu";

            return(msg);
        }
Example #21
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable     currentTable = this.Tables.FirstOrDefault(t => t.TableNumber == tableNumber);
            IBakedFood currentFood  = this.BakedFoods.FirstOrDefault(f => f.Name == foodName);

            if (currentTable == null)
            {
                return(string.Format(OutputMessages.WrongTableNumber, tableNumber));
            }
            if (currentFood == null)
            {
                return(string.Format(OutputMessages.NonExistentFood, foodName));
            }

            currentTable.OrderFood(currentFood);
            //this.totalOrderedFoods.Add(currentFood);
            return(string.Format(OutputMessages.FoodOrderSuccessful, currentTable.TableNumber, foodName));
        }
Example #22
0
        public string OrderFood(int tableNumber, string foodName)
        {
            table = tables.FirstOrDefault(x => x.TableNumber == tableNumber);
            if (table == null)
            {
                return(string.Format(OutputMessages.WrongTableNumber, tableNumber));
            }

            food = bakedFoods.FirstOrDefault(x => x.Name == foodName);
            if (food == null)
            {
                return(string.Format(OutputMessages.NonExistentFood, foodName));
            }

            table.OrderFood(food);

            return(string.Format(OutputMessages.FoodOrderSuccessful, tableNumber, foodName));
        }
Example #23
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable     table = tables.FirstOrDefault(t => t.TableNumber == tableNumber);
            IBakedFood food  = bakedFoods.FirstOrDefault(f => f.Name == foodName);

            if (table == null)
            {
                return($"Could not find table {tableNumber}");
            }

            if (food == null)
            {
                return($"No {food} in the menu");
            }

            table.OrderFood(food);
            return($"Table {tableNumber} ordered {food}");
        }
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

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

            resturantObjects["food"].Add(food);
            return($"Added {food.Name} ({food.GetType().Name}) to the menu");
        }
Example #25
0
        public IBakedFood CreateFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

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

            return(food);
        }
Example #26
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable table = GetTable(tableNumber);

            if (table == null)
            {
                return($"Could not find table {tableNumber}");
            }

            IBakedFood bakedFood = GetFood(foodName);

            if (bakedFood == null)
            {
                return($"No {foodName} in the menu");
            }

            table.OrderFood(bakedFood);

            return($"Table {tableNumber} ordered {foodName}");
        }
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable targetTable = tables.FirstOrDefault(t => t.TableNumber == tableNumber);

            if (targetTable == null)
            {
                return($"Could not find table {tableNumber}");
            }

            IBakedFood targetFood = bakedFoods.FirstOrDefault(f => f.Name == foodName);

            if (targetFood == null)
            {
                return($"No {foodName} in the menu");
            }

            targetTable.OrderFood(targetFood);

            //TODO: MUST USE VARIABLES INSTEAD OF PROPERTIES OF TARGETOBJECTS?
            return($"Table {tableNumber} ordered {foodName}");
        }
Example #28
0
        public string AddFood(string type, string name, decimal price)
        {
            IBakedFood food = null;

            if (type == "Bread")
            {
                food = new Bread(name, price);
            }
            else if (type == "Cake")
            {
                food = new Cake(name, price);
            }
            if (food != null)
            {
                this.bakedFoods.Add(food);
                return($"Added {food.Name} ({food.GetType().Name}) to the menu");
            }
            else
            {
                return(String.Empty);
            }
        }
Example #29
0
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable table = tables.FirstOrDefault(x => x.TableNumber == tableNumber);

            if (table == null)
            {
                return($"{string.Format(Utilities.Messages.OutputMessages.WrongTableNumber, tableNumber)}");
            }
            else
            {
                IBakedFood food = bakedFoods.Where(x => x.Name == foodName).FirstOrDefault();
                if (food == null)
                {
                    return($"{string.Format(Utilities.Messages.OutputMessages.NonExistentFood, foodName)}");
                }
                else
                {
                    table.OrderFood(food);
                    return($"{string.Format(Utilities.Messages.OutputMessages.FoodOrderSuccessful, tableNumber, foodName)}");
                }
            }
        }
        public string OrderFood(int tableNumber, string foodName)
        {
            ITable table = resturantObjects["table"].FirstOrDefault(t => (t as ITable).TableNumber == tableNumber) as ITable;

            if (table == null)
            {
                return($"Could not find table { tableNumber}");
            }
            else
            {
                IBakedFood food = resturantObjects["food"].FirstOrDefault(f => (f as IBakedFood).Name == foodName) as IBakedFood;
                if (food == null)
                {
                    return($"No {foodName} in the menu");
                }
                else
                {
                    table.OrderFood(food);
                    return($"Table {tableNumber} ordered {foodName}");
                }
            }
        }