Setup

Consider a class Creature for creatures that have a name, can speak, and can act and a main method that creates four Creatures and has each act five times:
public class Creature {
    protected String name; // Creature's name

    // constructor: initialize name to n
    public Creature(String n) { 
        name = n; 
    }

    // speak, i.e. vocalize
    public void speak() { 
        System.out.println(name + " speaks"); 
    }

    // perform an action
    public void act() { 
        speak(); 
    }
}

// create 4 Creatures and repeatedly (5 times) 
// have each act one at a time
public class CUCSApplication {
    public static void main(String args[]) {
        Creature[] c = { // 4 Creatures
            new Creature("Butch"), 
            new Creature("Fluffy"), 
            new Creature("Sleepy"), 
            new Creature("Clarus") 
        };
        // repeat 5 times: each Creature acts
            for (int times=5; times>0; times--)
                for (int i = 0; i<c.length; i++)        
                    c[i].act();
    }
}
(Observe the use of an array to reduce redundancy.)


What To Do

Compile and run the given code to see the behavior of the generic Creature. Define the following sub-classes and define/override methods as specified: Turn in a printout of your Java code for Creature, Cat, Dog, DogCow, and the main method, and a printout of the output from main.