// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; namespace E { public abstract class Animal { private string name; public Animal(string name) { this.name = name; } public string Name { get { return name; } } public abstract string Type { get; } public abstract string Description { get; } } public abstract class Bird : Animal { public Bird(string name) : base(name) { } public override string Description { get { return Name + " is a " + Type + " with max. wingspan of " + Wingspan; } } public abstract double Wingspan { get; } } public class Eagle : Bird { public Eagle(string name) : base(name) { } public override string Type { get { return "Eagle"; } } public override double Wingspan { get { return 2.0; } } } public abstract class Mammal : Animal { public Mammal(string name) : base(name) { } public override string Description { get { return Name + " is a " + Type + " with max. weight of " + Weight + " and max. height of " + Height; } } public abstract double Weight { get; } public abstract double Height { get; } } public class Elephant : Mammal { public Elephant(string name) : base(name) { } public override string Type { get { return "Elephant"; } } public override double Weight { get { return 4000.0; } } public override double Height { get { return 3.0; } } } public class Program { public static void Main(string[] args) { List alst = new List(); alst.Add(new Eagle("Eddie")); alst.Add(new Elephant("Dumbo")); foreach(Animal a in alst) { Console.WriteLine(a.Description); } } } }