1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
public class Dog { private string name; public Dog(string name) { this.name = name; } public string Speak() { return "woof"; } public bool Validate() { return name.Length > 0; } } public class Cat { private string name; public Cat(string name) { this.name = name; } public string Speak() { return "meow"; } public bool Validate() { return name.Length > 0 && name.Length < 50; } } public class Shelter { private List<object> animals = new List<object>(); public void Add(object animal) { animals.Add(animal); } public int Count() { return animals.Count; } }