Class Cat

java.lang.Object
  |
  +--Cat

public class Cat
extends java.lang.Object

One of several barnyard animals. Note that these animals are similar to, but somewhat different from, the examples I have been giving in class.


Field Summary
(package private)  double currentWeight
          the weight of this Cat in pounds.
(package private)  double mealSize
          the serving size of one meal for this Cat in pounds.
(package private)  java.lang.String name
          the name of this Cat.
 
Constructor Summary
Cat(java.lang.String theName)
          Create a new Cat with default characteristics.
Cat(java.lang.String theName, double serving, double weight)
          Create a new Cat, using supplied parameter values.
 
Method Summary
 void eat(double pounds)
          Eat some goodies.
 double getMealSize()
          Retrieve the meal size for this Cat.
 java.lang.String getName()
          Retrieve the name of this Cat.
static void main(java.lang.String[] args)
          Run this Cat through a typical day.
 void meow()
          Provide this Cat with a voice.
 void sleep()
          Provide this Cat with a way to rest when weary.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentWeight

double currentWeight
the weight of this Cat in pounds.

mealSize

double mealSize
the serving size of one meal for this Cat in pounds.

name

java.lang.String name
the name of this Cat.
Constructor Detail

Cat

public Cat(java.lang.String theName)
Create a new Cat with default characteristics. This constructor sets a default meal size of 0.1 pound and an initial weight of 1 pound.
Parameters:
theName - name of this Cat

Cat

public Cat(java.lang.String theName,
           double serving,
           double weight)
Create a new Cat, using supplied parameter values.
Parameters:
theName - name of this Cat
serving - the size of a single meal for this Cat in pounds
weight - the initial weight of this Cat 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()
Retrieve the meal size for this Cat.
Returns:
the meal size specified for this Cat.

getName

public java.lang.String getName()
Retrieve the name of this Cat.
Returns:
the name specified for this Cat.

main

public static void main(java.lang.String[] args)
Run this Cat through a typical day. This is a simple test harness for this class.
Parameters:
args - ignored

meow

public void meow()
Provide this Cat with a voice.

sleep

public void sleep()
Provide this Cat with a way to rest when weary.


Generated by BlueJ