CSCI 3326
Assignment #3
Due date: Start of class Monday, 1/26/2009
Hand in:
1) Turn in your source code
to me as an email attachment. The
subject of the email must be:
cs3326hwk3
2) Also turn in a hardcopy
of your source code along with a printout of a sample run.
Extend
the Kennel class we created during Wednesday’s class period by writing the 3
methods:
void boardDog( Dog d )
Dog retrieveDog( String name )
String toString()
As
an example, write your methods such that the following block of code will yield
something similar to the output below:
Example
code:
Dog grendel;
//declare variable of type dog
Dog blapjack;
Dog newpuppy;
Dog zelda;
Kennel thepound;
//create
some dogs to test the kennel
grendel = new Dog("Grendel", "Blue Heeler", 25, 24);
blapjack = new Dog("BlapJack", "Great Dane", 70, 80);
newpuppy = grendel.mate(blapjack);
zelda = new Dog("Zelda",
"Pembroke Welsch Corgi", 40, 10);
//create a
kennel to board the dogs in
thepound = new Kennel(); //create
a new Dog kennel to store all the dogs
thepound.boardDog(grendel);
thepound.boardDog(blapjack);
thepound.boardDog(zelda);
thepound.boardDog(newpuppy);
thepound.retrieveDog("Zelda");
System.out.println(thepound);
The
above code should cause something like the following to be displayed:
Retrieving Zelda the Pembroke Welsch Corgi with a bmi of 281.2
from the pound
Cage 0 contains: Grendel
the Blue Heeler with a bmi of 30.51215277777778
Cage 1 contains: BlapJack
the Great Dane with a bmi of 7.6890625
Cage 2 is EMPTY
Cage 3 contains: Milo the Blue
Heeler-Great Dane with a bmi of 12.349297337278106
Cage 4 is EMPTY
Cage 5 is EMPTY
Cage 6 is EMPTY
Cage 7 is EMPTY
Cage 8 is EMPTY
Cage 9 is EMPTY