Exemple #1
0
 public void Feed(IFood food)
 {
     if (!this.PrefferedFood.Contains(food.GetType()))
     {
         throw new InvalidOperationException(string.Format(INVALID_FOOD, this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += food.Quantity * this.WeightMultiplyer;
     this.FoodEaten += food.Quantity;
 }
Exemple #2
0
        public override void Eat(IFood food)
        {
            if (!(food is Meat))
            {
                WrongFoodException(food);
            }

            base.Eat(food, FOOD_INCREASE);
        }
        public string AddFood(string type, string name, decimal price)
        {
            //fix if foog is null
            IFood food = this.foodFactory.CreateFood(type, name, price);

            menu.Add(food);

            return($"Added {name} ({type}) with price {price:f2} to the pool");
        }
        public ActionResult EnableDish(string id)
        {
            var db = new IFood();

            db.Dishes.Where(d => d.Id.ToString().Equals(id)).FirstOrDefault <Dish>().IsActive = true;
            db.SaveChanges();

            return(RedirectToAction("AdminIndex", "Admin"));
        }
Exemple #5
0
 public void Feed(IFood food)
 {
     if (!PreferredFoods.Contains(food.GetType()))
     {
         throw new UneatableFoodException(String.Format(UneatableFoodMessage, GetType().Name, food.GetType().Name));
     }
     Weight    += WeightMultiplier * food.Quantity;
     FoodEaten += food.Quantity;
 }
Exemple #6
0
        public void Run()
        {
            string input;
            var    countLines = 0;

            while ((input = Console.ReadLine()) != "End")
            {
                try
                {
                    if (countLines % 2 == 0)
                    {
                        try
                        {
                            var animalInfo = input.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
                            animal = animalFactory.CreateAnimal(animalInfo);
                            countLines++;
                            continue;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            var foodInfo = input.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
                            food = foodFactory.CreateFood(foodInfo);
                            countLines++;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }

                    try
                    {
                        Console.WriteLine(animal.ProduceSound());
                        animal.Eat(food);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    animals.Add(animal);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            animals.ForEach(a => Console.WriteLine(a));
        }
Exemple #7
0
        private void Eat(GameObject food)
        {
            IFood foodItem = food.GetComponent <IFood>();

            if (foodItem != null)
            {
                float calories = foodItem.GetEaten();
                RestoreEnergy(calories);
            }
        }
Exemple #8
0
    public void Eat(IFood food)
    {
        var vegetable = food as IVegetable;

        if (vegetable == null)
        {
            return;
        }
        Eat(vegetable);
    }
Exemple #9
0
    public void Eat(IFood food)
    {
        var meat = food as IMeat;

        if (meat == null)
        {
            return;
        }
        Eat(meat);
    }
        }                                                          //всеки клас е някакъв тип данни и може да се вземе типа с getType.
        //тук можем да слижим Type Meat, Type Veretable. Не може да бъде от IFood, понеже класовете са референтни типове

        public void Feed(IFood food)
        {
            if (!this.PrefferedFoods.Contains(food.GetType())) //съдържа ли типа тази храна
            {
                throw new UneatableFoodException
                          (string.Format(UneatableFoodMessage, this.GetType().Name, food.GetType().Name));
            }
            this.Weight    += this.WeightMultiplayer * food.Quantity;
            this.FoodEaten += food.Quantity;
        }
        public ActionResult chageOderStatus(String id, int status)
        {
            status = (status + 1) % 3; // chỗ này click vào status sẽ đổi từ pending -> success -> cancel -> pending
            var db = new IFood();

            db.Transactions.Where(d => d.Id.ToString().Equals(id)).FirstOrDefault <Transaction>().Status = status;
            db.SaveChanges();

            return(RedirectToAction("OrdersIndex"));
        }
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = this.foodFactory.CreateFood(type, name, price);

            this.menu.Add(food);

            string result = $"Added {name} ({food.GetType().Name}) with price {price:F2} to the pool";

            return(result);
        }
Exemple #13
0
        public void Feed(IFood food)
        {
            if (!this.PreferredFoods.Contains(food.GetType()))
            {
                throw new InvalidOperationException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }

            this.FoodEaten += food.Quantity;
            this.Weight    += food.Quantity * WeightMultiplier;
        }
Exemple #14
0
        public IFood CreateFood(string type, string name, decimal price)
        {
            Type foodType = Assembly.GetCallingAssembly()
                            .GetTypes()
                            .FirstOrDefault(t => t.Name == type);

            IFood food = (IFood)Activator.CreateInstance(foodType, name, price);

            return(food);
        }
 public void Eat(IFood food)
 {
     if (!this.PrefferedFoods.Contains(food.GetType()))
     {
         throw new InvalidOperationException
                   (String.Format(DEF_EXC_MSG, this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += this.WeightMultiplier * food.Quantity;
     this.FoodEaten += food.Quantity;
 }
Exemple #16
0
        public void Feed(IFood food)
        {
            if (!PreferredFoods.Contains(food.GetType()))
            {
                throw new InvalidOperationException(String.Format(INV_FOOD_TYPE, this.GetType().Name, food.GetType().Name));
            }

            FoodEaten += food.Quantity;
            Weight    += food.Quantity * WeightMultiplier;
        }
Exemple #17
0
        public IFood AddExtras(IFood mainFood, IEnumerable <string> extras)
        {
            var result = mainFood;

            foreach (var extra in extras)
            {
                result = ExtrasCooker[extra](result);
            }
            return(result);
        }
Exemple #18
0
 public void ConsumeFood(IFood food)
 {
     if (!IsAlive)
     {
         return;
     }
     Health = Math.Min(MaxHealth, Health + food.HealthValue);
     CheckFishHealth();
     food.Consume();
 }
Exemple #19
0
        public void Eating(IFood food)
        {
            if (!this.FoodTypes.Contains(food.GetType()))
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }

            this.Weight    += WeightMultiplier * food.Quantity;
            this.FoodEaten += food.Quantity;
        }
Exemple #20
0
        public override void Eat(IFood food)
        {
            var canEat = Validator.ValidateVegetableAndMeatEating(this.GetType().Name, food.GetType().Name);

            if (canEat)
            {
                Weight    += WeightIncrease * food.Quantity;
                FoodEaten += food.Quantity;
            }
        }
Exemple #21
0
        public IFood Cook(Order order)
        {
            IFood mainFood           = CreateMainFood(order.Food);
            IFood mainFoodWithExtras = AddExtras(mainFood, order.Extras);

            Console.WriteLine($"Food prepeared: {mainFood.MainFoodName} with {mainFoodWithExtras.ExtraFoodName}");
            mainFoodWithExtras.MainFoodName = mainFood.MainFoodName;

            return(mainFoodWithExtras);
        }
        public void Feed(IFood food)
        {
            if (!this.Foods.Contains(food.GetType()))
            {
                throw new NotValidFoodException(FoodExc);
            }

            this.FoodEaten += food.Quantity;
            this.Weight    += food.Quantity * this.WeightGain;
        }
Exemple #23
0
        public void Feed(IFood food)
        {
            if (!this.PrefferedFoodTypes.Contains(food.GetType()))
            {
                throw new InvalidOperationException(String.Format(ExceptionMessages.InvalidFoodTypeException, this.GetType().Name, food.GetType().Name));
            }

            this.Weight    += food.Quantity * this.WeightMultiplier;
            this.FoodEaten += food.Quantity;
        }
        public void Feed(IFood food)
        {
            if (!this.PrefferedFoods.Contains(food.GetType()))
            {
                throw new FoodException(string.Format(FoodMessage, this.GetType().Name, food.GetType().Name));
            }

            this.Weight    += this.WeightMultiplier * food.Quantity;
            this.FoodEaten += food.Quantity;
        }
        public void Feed(IFood food)
        {
            if (!this.PrefferedFoods.Contains(food.GetType()))
            {
                throw new UneatableFoodException(String.Format(Uneatable_Food_Exception_Msg, this.GetType().Name, food.GetType().Name));
            }

            this.Weight    += this.WeightMultiplier * food.Quantity;
            this.FoodEaten += food.Quantity;
        }
Exemple #26
0
        public void Feed(IFood food)
        {
            if (!this.PreferredFood.Contains(food.GetType()))
            {
                throw new UneatableFoodExc(String.Format(UneatableFoodMessage, this.GetType().Name, food.GetType().Name));
            }

            this.Weight    += this.WeightMultiplier * food.Quantity;
            this.FoodEaten += food.Quantity;
        }
 public void ServerOrders()
 {
     Console.WriteLine($"WaitressRobot: Processing {Orders.Count} order(s)...");
     foreach (var order in Orders)
     {
         IFood food = Kitchen.Cook(order);
         order.NotifyReady(food);
     }
     Console.WriteLine("WaitressRobot: Orders processed.");
 }
Exemple #28
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = this.foodFactory.CreateFactory(type, name, price);

            menu.Add(food);

            var classType = food.GetType().Name;

            return($"Added {name} ({type}) with price {food.Price:f2} to the pool");
        }
        public override void FeedAnimal(IFood foodType)
        {
            if (foodType.GetType().Name != "Meat")
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {foodType.GetType().Name}!");
            }

            this.Weight    += 0.40 * foodType.Quantity;
            this.FoodEaten += foodType.Quantity;
        }
 public override void Eat(IFood food, int quantity)
 {
     if (!(food is Vegetable) && !(food is Fruit))
     {
         base.WrongFood(food);
     }
     else
     {
         base.Eat(food, quantity);
     }
 }
Exemple #31
0
 public void FeedAnimal(IFood food)
 {
     // animate
     Eat(3f);
     // handles food values
     this._hunger += food.calories;
     this._thirst += food.rehydration;
     // handles pet preferences
     int pleasureAmnt = 0;
     // what the pet wants - what they get = pleasure level
     // NOTE: pleasureAmnt could be negative
     pleasureAmnt += food.fishey - _Prefs.fishPref;
     pleasureAmnt += food.meaty - _Prefs.meatPref;
     pleasureAmnt += food.watery - _Prefs.wateryPref;
     pleasureAmnt += food.sweet - _Prefs.sweetPref;
     // adds to pets happiness
     happiness += pleasureAmnt;
     // bladder effects
     bladderCapacity -= (int)((food.calories + food.rehydration) / 2);
     CalculateHealth();
 }
 /// <summary>
 /// Initializes a new instance of the EatOperator class.
 /// </summary>
 /// <param name="avatar">The avatar performing the action</param>
 /// <param name="food">The food that will be consumed</param>
 public EatOperator(Avatar avatar, IFood food)
 {
     _food = food;
     _avatar = avatar;
 }
Exemple #33
0
 public string Post(IFood food)
 {
     string value = food.ToString();
     return string.Format("Food: ({0}), Response: ({1})", food.Name, value);
     // Moet de return value hiervan ook een Bundle worden?
 }
 public FoodViewModel(IFood food)
     : base()
 {
     Food = food;
 }
 /// <summary>
 /// Attempt to eat the given object
 /// </summary>
 /// <param name="food">The food to be consumed</param>
 /// <returns>An object used to complete the operation</returns>
 public EatOperator Eat(IFood food)
 {
     return new EatOperator(this, food);
 }
Exemple #36
0
 public void PushFood(IFood food)
 {
     ITamagotchiState tamagotchiState;
     _foodReaction.React(food, State, out tamagotchiState);
     State = tamagotchiState;
 }
 internal static EntityViewModel CreateFoodViewModel(IFood food)
 {
     return new FoodViewModel(food);
 }