Class Dog

java.lang.Object
  |
  +--Dog
All Implemented Interfaces:
Acrobat, java.lang.Comparable

public class Dog
extends java.lang.Object
implements Acrobat, java.lang.Comparable

One of several animal types, in this case, a canine. This class of Dogs is special because it can also do Acrobat functions.


Constructor Summary
Dog(java.lang.String theName)
          Create a new Dog with default characteristics.
Dog(java.lang.String theName, double serving, double weight)
          Create a new Dog, using supplied parameter values.
 
Method Summary
 void clap(int k)
          Clap as instructed.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
 void eat(double pounds)
          Eat some goodies.
 boolean equals(java.lang.Object obj)
          Compares this Dog to the specified object.
 int getActionCount()
          Tell the caller how many things we've done so far.
 double getCurrentWeight()
          get the current weight of this animal.
 double getMealSize()
          get the meal size defined for this animal.
 java.lang.String getName()
          get the name of this animal.
 int hashCode()
          Returns a hash code for this Dog.
 java.lang.String toString()
          Return a descriptive String.
 void twirl(int k)
          Twirl around as instructed.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dog

public Dog(java.lang.String theName)
Create a new Dog with default characteristics. This constructor sets a default meal size of 1 pound and an initial weight of 40 pound.

Parameters:
theName - name of this animal

Dog

public Dog(java.lang.String theName,
           double serving,
           double weight)
Create a new Dog, using supplied parameter values.

Parameters:
theName - name of this animal
serving - the size of a single meal for this animal in pounds
weight - the initial weight of this animal in pounds
Method Detail

eat

public void eat(double pounds)
Eat some goodies. There is some weight gain after eating.

Parameters:
pounds - the number of pounds of food provided.

getMealSize

public double getMealSize()
get the meal size defined for this animal.

Returns:
meal size in pounds

getCurrentWeight

public double getCurrentWeight()
get the current weight of this animal.

Returns:
weight in pounds

getName

public java.lang.String getName()
get the name of this animal.

Returns:
the name

twirl

public void twirl(int k)
Twirl around as instructed.

Specified by:
twirl in interface Acrobat
Parameters:
k - the number of times to twirl

clap

public void clap(int k)
Clap as instructed.

Specified by:
clap in interface Acrobat
Parameters:
k - the number of times to clap

getActionCount

public int getActionCount()
Tell the caller how many things we've done so far.

Specified by:
getActionCount in interface Acrobat
Returns:
the number of claps and twirls to date

compareTo

public int compareTo(java.lang.Object obj)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The other object must be a Dog, and the comparison is based on their name fields.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public boolean equals(java.lang.Object obj)
Compares this Dog to the specified object. The result is true if and only if the argument is not null and is a Dog object with the same sequence of characters in the name field.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Dog to compare this Dog against.
Returns:
true if the names are equal; false otherwise.

hashCode

public int hashCode()
Returns a hash code for this Dog. The hashcode is the same as the hashcode for the name field.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

public java.lang.String toString()
Return a descriptive String.

Overrides:
toString in class java.lang.Object