コード例 #1
0
ファイル: Tiger.cs プロジェクト: rosenkolev1/SoftUni-1
 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;
 }
コード例 #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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        }                                                          //всеки клас е някакъв тип данни и може да се вземе типа с 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;
        }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #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;
 }
コード例 #8
0
ファイル: Dog.cs プロジェクト: todordiklich/CSharp-Advanced
 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}!");
     }
 }
コード例 #9
0
ファイル: Tiger.cs プロジェクト: MarioGn1/SoftUni
        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}!");
            }
        }
コード例 #10
0
    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);
        }
    }
コード例 #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");
        }
コード例 #12
0
        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}!");
            }
        }
コード例 #13
0
        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");
        }
コード例 #14
0
        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());
        }
コード例 #15
0
        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;
        }
コード例 #16
0
 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;
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
        }
コード例 #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;
 }
コード例 #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;
 }
コード例 #22
0
ファイル: Dog.cs プロジェクト: vankatalp360/C-OOP-Basics
        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;
            }
        }
コード例 #23
0
ファイル: Animal.cs プロジェクト: DenitsaDey/C-Sharp_OOP
        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;
        }
コード例 #24
0
ファイル: Animal.cs プロジェクト: svetlyoek/OOP
        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;
        }
コード例 #25
0
        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;
        }
コード例 #26
0
        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);
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #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}!");
     }
 }