// Constructor
 public AnimalWorld(ContinentFactory factory)
 {
     carnivore = factory.CreateCarnivore();
     herbivore = factory.CreateHerbivore();
 }
 public override void Eat(Herbivore h)
 {
     // Eat Bison
     Console.WriteLine($"{GetType().Name} eats {h.GetType().Name}");
 }
예제 #3
0
 public override void Eat(Herbivore h)
 {
     // eat wildbeast
     Console.WriteLine(this.GetType().Name +
                       " eats " + h.GetType().Name);
 }
 public abstract void Eat(Herbivore h);
예제 #5
0
 // Constructor
 public AnimalWorld(RealWorldAbstractFactory abstractFactory)
 {
     _carnivore = abstractFactory.CreateCarnivore();
     _herbivore = abstractFactory.CreateHerbivore();
 }