Abstract


Abstract

MusicalInstrument.java
WoodWind.java
Percussion.java
Clarinet.java
Saxophone.java
Timpani.java
Glockenspiel.java
TestHarness.java

Read chapter 8, 9, 10


Classwork


Create an abstract class Creature with an instance variable strength and abstract methods:  eat(), which will represent the animal eating, call(),  which will represent the sound the animal makes, and move() which will represent how it moves.  (When you fill in these methods later, you will mostly just print out messages saying what they do for each specific class.) 

In your main, create an array of 10 Creatures (you will fill it with your actual creature types later).  Write code that would print each one in the array and then have it eat, move, and do its call.  Notice you can write this code without having created any non-abstract classes and their methods, but you can't run yet.

Inheriting from Creature, create abstract classes to represent carnivores, which only eat meat, and herbivores, which only eat vegetables. Have each eat method print what the creature is eating (meat or vegetables) and add +2 to strength for vegetables and +5 to strength for meat. 

Then create four non-abstract classes for specific types of creature, two of which are carnivores, and two herbivores (you may create any type of creature that amuses you).  

For these final four creature classes, don't override eat (already filled in for eating meat or vegetables) but fill in move and call in ways appropriate to the creature.  Give one of the classes an appropriate extra instance variable which is used in some way in move or call, and for at least one other creature use strength  in some way in move or call. 

In these classes, provide parameterized constructors that take strength (and any other instance vars) and have them chain back to superclass constructors. Then go back into main and fill up your array with various creatures and see that the code you wrote successfully calls all the different versions of the eat, call, and move methods.

[EC] Give all classes copy constructors (chain!).  Give Creature an abstract clone method and all non-abstract classes their own clone methods.

[EC] Give all non-abstract classes equals methods where each can only be equals to others of its own type with strength and any additional instance variables the same.