class Program { static void Main(string[] args) { List<Animal> animals = new List<Animal>(); animals.Add(new Dog("Vovka", 12)); animals.Add(new Dog("Ura", 0)); foreach(Animal el in animals) { Console.WriteLine(); //What should I write????? } Console.ReadKey(); } } class Animal { public string name { get; set; } public Animal(string name) { this.name = name; } protected virtual void print() { Console.WriteLine("Name:"); Console.WriteLine(name); } } class Dog : Animal { public int happy { get; set; } public int Happy { get { return happy; } set { if(value>10) { happy = 10; } else { happy = value; } } } public Dog(string name,int happy) : base(name) { Happy = happy; print(); } protected override void print() { base.print(); Console.WriteLine("Happy:"); Console.WriteLine(happy); Console.WriteLine(""); } } Closed due to the fact that the subject of the question is not clear to Nicolas Chabanovsky ♦ Jan 9 '17 at 6:27 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
Console.WriteLine(); //What should I write?????Console.WriteLine(); //What should I write?????callprint:el.print()- Grundyprintpublic yet. - αλεχολυτ