| CIT
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."
Details:
Define an interface Speaker with one method, String talk().
Define an abstract class Animal which implements Speaker.
It should have one method, ,
which returns 4.
Define three (concrete) subclasses of Animal: Dog,
Cat, and Bird. Since these are to be concrete classes,
they will have to implement the talk() method (dogs say "Woof!",
cats say "Meow!", and birds say "Cheep!").
In addition, each should have a toString() method to return their
type ("dog", "cat", or "bird").
Finally, since birds have only two legs, the Bird class should
override the getNumberOfLegs() method.
Finally, write a Zoo class that holds an array of ten Animals.
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.