static void Main(string[] args) { Animal animal = new Animal(); Dog dog = new Dog(); Cat cat = new Cat(); Chiuaua chiuaua = new Chiuaua(); List <IAnimal> animals = new List <IAnimal>(); animals.Add(animal); animals.Add(dog); animals.Add(cat); animals.Add(chiuaua); foreach (IAnimal species in animals) { species.MakeSound(); species.SetName("Sellu"); species.PrintInfo(); species.Jump(); species.Jump(); species.Jump(); species.Jump(); } }
public static void Main() { Dog MyDog = new Dog(); MyDog = new GermanShepard(); MyDog.Bark(); // prints Rrrrooouuff!! MyDog = new Chiuaua(); MyDog.Bark(); // prints ruff; }