591 Lab Assignment: Animals
Fall 2004, David Matuszek
This is not for credit, so don't hand it in!
Purposes of this assignment:
General idea of the assignment:
Do a few simple things with "animals."
Define an interface
Speaker with one method,
Define an abstract class
Animal which implements
It should have one method,
Define three (concrete) subclasses of
Bird. Since these are to be concrete classes,
they will have to implement the
talk() method (dogs say
"Meow!", and birds say
In addition, each should have a
toString() method to return their
Finally, since birds have only two legs, the
Bird class should
Finally, write a
Zoo class that holds an array of ten
This class will hold your
main method. In this class, fill the
array randomly (use a random number generator) with dogs, cats, and birds. After
the array is full, loop through the array and, for each element, print out a
message such as:
The dog has 4 legs and says "Woof!"
If you can get all this working, try to write JUnit tests for your animal classes. I have an Eclipse FAQ that may come in handy.
Due date: None--don't hand this in.