Beispiel #1
0
 public override void Feed(IFood foodType, int quantity)
 {
     if (foodType.GetType().Name != "Meat")
     {
         throw new ArgumentException($"{this.GetType().Name} does not eat {foodType.GetType().Name}!");
     }
     this.FoodEaten += quantity;
     this.Weight    += quantity * 1.00;
 }
Beispiel #2
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;
        }
        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;
        }
        }                                                          //всеки клас е някакъв тип данни и може да се вземе типа с 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 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;
 }
 public void Feed(IFood food)
 {
     if (!FoodPreferred.Contains(food.GetType()))
     {
         throw new InvalidOperationException(
                   string.Format(INV_FOOD_EXC_MSG,
                                 this.GetType().Name, food.GetType().Name));
     }
     FoodEaten += food.Quantity;
     Weight    += food.Quantity * WeightMultiplier;
 }
Beispiel #7
0
 public void Feed(IFood food)
 {
     if (!this.PreferedFoodTypes.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;
 }
Beispiel #8
0
 public override void Eat(IFood food)
 {
     if (food.GetType().Name == "Meat")
     {
         this.Weight    += food.Quantity * this.WeightIncrease;
         this.FoodEaten += food.Quantity;
     }
     else
     {
         Console.WriteLine($"{this.GetType().Name} does not eat {food.GetType().Name}!");
     }
 }
Beispiel #9
0
        public override void Feed(IFood food)
        {
            this.FoodType = TryParseFoodType(food.GetType().Name);

            if (this.FoodType == FoodType.Meat)
            {
                this.FoodEaten = food.Qty;
                this.Weight   += FoodEaten * INCRESE_WEIGHT_FACTOR;
            }
            else
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }
        }
    public bool checkOrders(IFood food)
    {
        int bestMatch = -1;

        for (int i = 0; i < tickets.Length; i++)
        {
            //if already found an order thats been waiting longer keep that one
            if (tickets[i] == null || food.GetType() != tickets[i].getFood().GetType() ||
                (bestMatch != -1 && tickets[bestMatch].getStartTime() < tickets[i].getStartTime()))
            {
                continue;
            }

            if (food.Compare(tickets[i].getFood()))
            {
                bestMatch = i;
            }
        }

        if (bestMatch != -1)
        {
            StartCoroutine(myGame.finishOrder(tickets[bestMatch].getTimeSpent()));
            deleteTicket(bestMatch);
            return(true);
        }
        else
        {
            StartCoroutine(myGame.failOrder());
            return(false);
        }
    }
Beispiel #11
0
        public string AddFood(string type, string name, decimal price) //ok
        {
            IFood food = this.foodFactory.CreateFood(type, name, price);

            menu.Add(food);
            return($"Added {food.Name} ({food.GetType().Name}) with price {food.Price:f2} to the pool");
        }
        private void CheckFood(IFood food)
        {
            var foodsAndAnimals = new Dictionary <string, List <string> >();

            foodsAndAnimals.Add("Hen", new List <string>()
            {
                "Vegetable", "Fruit", "Meat", "Seeds"
            });
            foodsAndAnimals.Add("Mouse", new List <string>()
            {
                "Vegetable", "Fruit"
            });
            foodsAndAnimals.Add("Cat", new List <string>()
            {
                "Vegetable", "Meat"
            });
            foodsAndAnimals.Add("Tiger", new List <string>()
            {
                "Meat"
            });
            foodsAndAnimals.Add("Dog", new List <string>()
            {
                "Meat"
            });
            foodsAndAnimals.Add("Owl", new List <string>()
            {
                "Meat"
            });

            if (!foodsAndAnimals[this.GetType().Name].Contains(food.GetType().Name))
            {
                throw new InvalidFoodTypeException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }
        }
        public string AddFood(string type, string name, decimal price)
        {
            IFood createdFood = foodFactory.CreateFood(type, name, price);


            this.menu.Add(createdFood);
            return($"Added {createdFood.Name} ({createdFood.GetType().Name}) with price {createdFood.Price:f2} to the pool");
        }
        public void Feed(IFood food)
        {
            Debug.Log(string.Format("Feeding a {0} with {1}", this.GetType().Name, food.GetType().Name));

            HaveFuelForSecondsCount +=
                GameManager.Instance.SatietyDurationDictionaryService.GetSatietyForProduction(this.GetType(),
                                                                                              food.GetType());
        }
        public void Eat(IFood food)
        {
            MyException.CheckFood(this.GetType().Name, food.GetType().Name, this.FavouriteFood);

            this.Weight += this.WeightIncrease * food.Quantity;

            this.FoodEaten += food.Quantity;
        }
 public void Feed(IFood food)
 {
     if (!this.listFood.Contains(food.GetType()))
     {
         throw new InvalidOperationException(String.Format(ExceptionMessage.InvalidFoodType, this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += food.Quantity * WeightGroingCoeficient;
     this.FoodEaten += food.Quantity;
 }
Beispiel #17
0
 public void Feed(IFood food)
 {
     if (!this.PrefferedFoods.Contains(food.GetType()))
     {
         throw new ArgumentException(string.Format("{0} does not eat {1}!", this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += this.WeightMultiplier * food.Quantity;
     this.FoodEaten += food.Quantity;
 }
Beispiel #18
0
 public void Feed(IFood food)
 {
     if (!this.PrefferedFoods.Contains(food.GetType()))
     {
         throw new UneatableFoodExceptions(string.Format(UNEATABLE_FOOD_MESSAGE, this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += this.WeightMultiplier * food.Quantity;
     this.FoodEaten += food.Quantity;
 }
Beispiel #19
0
        }                                                        //abstract защото надолу за всяко животно ще е различна!

        public void Feed(IFood food)
        {
            if (!this.PreferredFoods.Contains(food.GetType()))
            {
                throw new InvalidOperationException(string.Format(INV_FOOD_TYPE, this.GetType().Name, food.GetType().Name));
            }
            this.FoodEaten += food.Quantity;
            this.Weight    += food.Quantity * this.WeightMultiplier;
        }
Beispiel #20
0
 public void Feed(IFood food)
 {
     if (!this.PreferedFood.Contains(food.GetType()))
     {
         throw new ArgumentException(string.Format(IVALID_FOOD_TYPE, this.GetType().Name, food.GetType().Name));
     }
     this.Weight    += food.Quantity * this.WeightMultiplier;
     this.FoodEaten += food.Quantity;
 }
Beispiel #21
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;
 }
Beispiel #22
0
        public override void Eat(IFood food)
        {
            var canEat = Validator.ValidateMeatEating(this.GetType().Name, food.GetType().Name);

            if (canEat)
            {
                Weight    += WeightIncrease * food.Quantity;
                FoodEaten += food.Quantity;
            }
        }
Beispiel #23
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;
        }
Beispiel #24
0
        public void Feed(IFood food)
        {
            if (!this.PrefferedFood.Contains(food.GetType()))
            {
                throw new InvalidOperationException(string.Format(InvalidTypeOfFood.invalidFoodType, this.GetType().Name, food.GetType().Name));
            }

            this.Weight    += food.Quantity * this.FoodMultiplier;
            this.FoodEaten += food.Quantity;
        }
        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;
        }
        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;
        }
        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);
        }
Beispiel #28
0
        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;
        }
Beispiel #29
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;
        }
Beispiel #30
0
 public override void Eat(IFood food, int quantity)
 {
     if (food is Meat)
     {
         this.Weight += quantity * calories;
     }
     else
     {
         throw new ArgumentException($"Tiger does not eat {food.GetType().Name}!");
     }
 }