예제 #1
0
파일: Lion.cs 프로젝트: Jarolim/HomeWork
 public int TryEatAnimal(Animal animal)
 {
     if (animal != null)
     {
         if (animal.Size <= (this.Size*2))
         {
             if (animal is Zombie)
             {
                 this.Size++;
                 return animal.GetMeatFromKillQuantity();
             }
             this.Size++;
             return animal.GetMeatFromKillQuantity();
         }
     }
     else
     {
         return 0;
     }
     return 0;
     //	if (this.Size >= animal.Size*2 && animal != null)
     //	{
     //		return animal.GetMeatFromKillQuantity();
     //	}
     //	return 0;
 }
예제 #2
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal == null || !(animal.Size <= this.Size || animal.State == AnimalState.Sleeping))
                return 0;

            return animal.GetMeatFromKillQuantity();
        }
예제 #3
0
파일: Boar.cs 프로젝트: K-Iliev/OOP-C-Sharp
 public int TryEatAnimal(Animal animal)
 {
     if (animal!=null&&this.Size>=animal.Size)
     {
         return animal.GetMeatFromKillQuantity();
     }
     return 0;
 }
예제 #4
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal != null && (animal.Size <= this.Size || animal.State ==                  AnimalState.Sleeping))
     {
         return animal.GetMeatFromKillQuantity();
     }
     else 
         return 0;
 }
예제 #5
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal != null && animal.Size <= this.Size)
     {
         var result = animal.GetMeatFromKillQuantity();
         return result;
     }
     return 0;
 }
예제 #6
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal == null || !(animal.Size <= this.Size * 2))
                return 0;

            this.Size++;

            return animal.GetMeatFromKillQuantity();
        }
예제 #7
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null && (animal.Size <= BoarDefaultSize))
            {
                return animal.GetMeatFromKillQuantity();
            }

            return 0;
        }
예제 #8
0
 public override int TryEatAnimal(Animal animal)
 {
     if (animal != null && animal.Size <= this.Size * 2)
     {
         this.IsEated = true;
         return animal.GetMeatFromKillQuantity();
     }
     return base.TryEatAnimal(animal);
 }
예제 #9
0
파일: Lion.cs 프로젝트: K-Iliev/OOP-C-Sharp
 public int TryEatAnimal(Animal animal)
 {
     if (this.Size * 2 >= animal.Size)
     {
         this.Size++;
         return animal.GetMeatFromKillQuantity();
     }
      return 0;
 }
예제 #10
0
        public int TryEatAnimal(Animal animal)
        {
            if(animal != null && (animal.Size <= this.Size * 2))
            {
                this.Size++;
                return animal.GetMeatFromKillQuantity();
            }

            return 0;
        }
예제 #11
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal != null && animal.Size <= (2 * this.Size))
     {
         this.Size++;
         return animal.GetMeatFromKillQuantity();
     }
     else
         return 0;
 }
예제 #12
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal!= null)
     {
         if (animal.State == AnimalState.Sleeping || this.Size >= animal.Size)
         {
             return animal.GetMeatFromKillQuantity();
         }
     }
     return 0;
 }
예제 #13
0
 public virtual int GetMeatFromKillQuantity(Animal animal)
 {
     if (animal.GetType() == typeof(Zombie))
     {
         return 10;
     }
     else
     {
         return animal.GetMeatFromKillQuantity();
     }
 }
예제 #14
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal == null) return 0; // no such animal
     // the eaten animal should be smaller than or equal to the wolf or otherwise it should sleep
     if (animal.State == AnimalState.Sleeping || animal.Size <= this.Size)
     {
         return animal.GetMeatFromKillQuantity();
     }
     // otherwise no food for the poor wolf
     return 0;
 }
예제 #15
0
 public int TryEatAnimal(Animal animal)
 {
     // The Boar should be able to eat any animal, which is smaller than him or as big as him.
     if (animal != null && animal.Size <= this.Size)
     {
         return animal.GetMeatFromKillQuantity();
     }
     else
     {
         return 0;
     }
 }
예제 #16
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null && animal.IsAlive)
            {
                if (animal.Size <= this.Size)
                {
                    return animal.GetMeatFromKillQuantity();
                }
            }

            return 0;
        }
예제 #17
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null)
            {
                if (this.Size >= animal.Size || animal.State == AnimalState.Sleeping)
                {
                    return base.GetMeatFromKillQuantity(animal);
                }
            }

            return 0;
        }
예제 #18
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null)
            {
                if (this.Size >= animal.Size)
                {
                    return base.GetMeatFromKillQuantity(animal);
                }
            }

            return 0;
        }
예제 #19
0
 public int TryEatAnimal(Animal animal)
 {
     int eatenMeat = 0;
     if (animal != null)
     {
         if (animal.Size <= this.Size || animal.State == AnimalState.Sleeping)
         {
             eatenMeat = animal.GetMeatFromKillQuantity();
         }
     }
     return eatenMeat;
 }
예제 #20
0
 public int TryEatAnimal(Animal animal)
 {
     // Wolf should be able to eat any animal smaller than or as big as him,
     // or any animal which is sleeping.
     if (animal != null && (animal.Size <= this.Size || animal.State == AnimalState.Sleeping))
     {
         return animal.GetMeatFromKillQuantity();
     }
     else
     {
         return 0;
     }
 }
예제 #21
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal == null) return 0; // no such animal

            // the eaten animal should be smaller than or equal to the boar
            if (animal.Size <= this.Size)
            {
                // take the food
                return animal.GetMeatFromKillQuantity();
            }
            // otherwise no food for the boar, go to eat plants first
            return 0;
        }
예제 #22
0
파일: Lion.cs 프로젝트: jesusico83/Telerik
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null)
            {
                if ((2 * this.Size) >= animal.Size)
                {
                    this.Size++;
                    return animal.GetMeatFromKillQuantity();
                }
            }

            return 0;
        }
예제 #23
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null)
            {
                if (this.Size >= animal.Size / 2)
                {
                    this.Size += 1;
                    return animal.GetMeatFromKillQuantity();
                }
            }

            return 0;
        }
예제 #24
0
 public int TryEatAnimal(Animal animal)
 {
     int posibleEatAnimalSize = this.Size * 2;
     int eatenMeat = 0;
     if (animal != null)
     {
         if (animal.Size <= posibleEatAnimalSize)
         {
             this.Size += 1;
             eatenMeat = animal.GetMeatFromKillQuantity();
         }
     }
     return eatenMeat;
 }
예제 #25
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal == null) return 0; // no such animal
     // the eaten animal should be at most twice by size than the lion
     if (animal.Size <= (this.Size*2))
     {
         // lion grows on each eat
         this.Size++;
         // take the food
         return animal.GetMeatFromKillQuantity();
     }
     // otherwise, go lion to grow enough, you are so small now
     return 0;
 }
예제 #26
0
 public int TryEatAnimal(Animal animal)
 {
     // The Lion should be able to eat any animal, which is at most twice larger than him (inclusive).
     // Also, the Lion should grow by 1 with each animal it eats.
     if (animal != null && animal.Size <= 2 * this.Size)
     {
         this.Size += this.growSizeBy;
         return animal.GetMeatFromKillQuantity();
     }
     else
     {
         return 0;
     }
 }
예제 #27
0
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null)
            {
                var meatEaten = 0;
                if (this.Size >= animal.Size / 2)
                {
                    meatEaten = animal.GetMeatFromKillQuantity();
                    this.Size++;
                }

                return meatEaten;
            }
            return 0;
        }
예제 #28
0
파일: Wolf.cs 프로젝트: AYankova/CSharp
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null && (animal.Size <= this.Size || animal.State == AnimalState.Sleeping))
            {
                if (animal.GetType().Name == "Zombie")
                {
                    return 10;
                }
                else
                {
                    return animal.GetMeatFromKillQuantity();
                }
            }

            return 0;
        }
예제 #29
0
파일: Lion.cs 프로젝트: AYankova/CSharp
        public int TryEatAnimal(Animal animal)
        {
            if (animal != null && animal.Size<= 2*this.Size)
            {

                if (animal.GetType().Name == "Zombie")
                {
                    return 10;
                }
                else
                {
                    this.Size += 1;
                    return animal.GetMeatFromKillQuantity();
                }
            }

            return 0;
        }
예제 #30
0
 public int TryEatAnimal(Animal animal)
 {
     if (animal != null)
     {
         int meatQuantity = animal.GetMeatFromKillQuantity();
         if (animal.Size <= this.Size)
         {
             return meatQuantity;
         }
         else
         {
             return 0;
         }
     }
     else
     {
         return 0;
     }
 }