示例#1
0
        public int EatPlant(Plant plant)
        {
            if (plant == null) return 0; // no such plant

            // Boar grows on each eat
            this.Size++;
            return plant.GetEatenQuantity(this.biteSize);
        }
示例#2
0
文件: Deer.cs 项目: Jarolim/HomeWork
 public int EatPlant(Plant p)
 {
     if (p != null)
     {
         return p.GetEatenQuantity(this.biteSize);
     }
     return 0;
 }
示例#3
0
        public int EatPlant(Plant plant)
        {
            if (plant != null)
            {
                return plant.GetEatenQuantity(this.boarBitSize);
            }

            return 0;
        }
示例#4
0
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.IsEated = true;
         return plant.GetEatenQuantity(2);
     }
     return 0;
 }
示例#5
0
        public int EatPlant(Plant p)
        {
            if (p != null)
            {
                return(p.GetEatenQuantity(this.biteSize));
            }

            return(0);
        }
示例#6
0
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.Size++;
         return plant.GetEatenQuantity(this.biteSize);
     }
     return 0;
 }
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.Size += 1;
         return(plant.GetEatenQuantity(this.biteSize));
     }
     return(0);
 }
示例#8
0
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.Size += 1;
         return plant.GetEatenQuantity(2);
     }
     return 0;
 }
示例#9
0
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.IsEated = true;
         return(plant.GetEatenQuantity(2));
     }
     return(0);
 }
示例#10
0
        public int EatPlant(Plant p)
        {
            if (p != null)
            {
                this.Size++;
                return(p.GetEatenQuantity(BiteSize));
            }

            return(0);
        }
示例#11
0
        public int EatPlant(Plant plant)
        {
            if (plant != null)
            {
                this.Grow();
                return(plant.GetEatenQuantity(BitSize));
            }

            return(0);
        }
示例#12
0
 public int EatPlant(Plant plant)
 {
     int eatenPlant = 0;
     if (plant != null)
     {
         eatenPlant = plant.GetEatenQuantity(Boar.BiteSize);
         this.Size++;
     }
     return eatenPlant;
 }
示例#13
0
        public int EatPlant(Plant plant)
        {
            if (plant != null)
            {
                this.Size++;
                return(plant.GetEatenQuantity(2));
            }

            return(0);
        }
示例#14
0
        public int EatPlant(Plant plant)
        {
            if (plant != null)
            {
                this.Size++;
                return(plant.GetEatenQuantity(InitialBoarBiteSize));
            }

            return(0);
        }
示例#15
0
        public int EatPlant(Plant plant)
        {
            if (plant != null)
            {
                this.Size++;
                return(plant.GetEatenQuantity(BoarBiteSize)); //Check if it is OK
            }

            return(0);
        }
示例#16
0
        public int EatPlant(Plant p)
        {
            if (p != null)
            {
                this.Size++;
                return p.GetEatenQuantity(BiteSize);
            }

            return 0;
        }
示例#17
0
文件: Boar.cs 项目: 2She2/CSharpOOP
        public int EatPlant(Plant plant)
        {
            int eatenPlantQuantity = 0;

            if (plant != null)
            {
                eatenPlantQuantity = plant.GetEatenQuantity(Boar.BoarBiteSize);
                this.Size++;
            }

            return(eatenPlantQuantity);
        }
示例#18
0
 // The Boar should be able to eat from any plant.
 // When eating from a plant, the Boar increases its size by 1.
 public int EatPlant(Plant plant)
 {
     if (plant != null)
     {
         this.Size += this.growSizeBy;
         return plant.GetEatenQuantity(this.biteSize);
     }
     else
     {
         return 0;
     }            
 }
示例#19
0
        public int EatPlant(Plant p)
        {
            if (p == null)
            {
                return(0);
            }

            int eaten = p.GetEatenQuantity(this.biteSize);

            if (eaten != 0)
            {
                this.Size++;
            }

            return(eaten);
        }
示例#20
0
        /// <summary>
        /// The Boar should be able to eat from any plant.
        /// The Boar always has a bite size of 2.
        /// When eating from a plant,
        /// the Boar increases its size by 1.
        /// </summary>
        /// <param name="plant"></param>
        /// <returns></returns>
        public int EatPlant(Plant plant)
        {
            try
            {
                MealValidation.CheckIfMealIsNull(plant);

                var quantityEaten = plant.GetEatenQuantity(Boar.BiteSize);

                this.GrowWhenEating(Boar.GrowWhenEatingPlantsWithAmount);

                return(quantityEaten);
            }
            catch (Exception)
            {
                return(0);
            }
        }
示例#21
0
        public int EatPlant(Plant p)
        {
            if (p == null)
                return 0;

            int eaten = p.GetEatenQuantity(this.biteSize);

            if (eaten != 0)
                this.Size++;

            return eaten;
        }