// 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) 
public class OopFun {
    public static void test(Animal a) {
        a.sayMany(3);
        System.out.println(a.getDescription());     
    }
    public static void main(String[] args) {
        test(new Dog());
        test(new Cat());
    }
}

interface Animal {
    public void sayOne();
    public void sayMany(int n);
    public String getDescription();
}

abstract class AnimalBase implements Animal {
    public abstract void sayOne();
    public abstract String getType();
    public void sayMany(int n) {
        for(int i = 0; i < n; i++) {
            sayOne();
        }
    }
    public String getDescription() {
        return "I am a " + getType();
    }
}

class Dog extends AnimalBase {
    public void sayOne() {
        System.out.println("Vov");
    }
    public String getType() {
        return "dog";
    }
}

class Cat extends AnimalBase {
    public void sayOne() {
        System.out.println("Mjav");
    }
    public String getType() {
        return "cat";
    }
}
