// 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}");
 }
Exemplo n.º 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);
Exemplo n.º 5
0
 // Constructor
 public AnimalWorld(RealWorldAbstractFactory abstractFactory)
 {
     _carnivore = abstractFactory.CreateCarnivore();
     _herbivore = abstractFactory.CreateHerbivore();
 }