Class Chicken
java.lang.Object
Chicken
A Java class that represents a Chicken. The state of the chicken is
its name, height and weight. It provides essential Chicken
functionality, like feeding it.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
feed()
Feeds the chicken, increasing the chicken's weight and heightint
Returns the chicken's height, in centimetersgetName()
Returns the chicken's namedouble
Returns the chicken's weight, in poundsstatic void
Tests the Chicken classvoid
setHeight
(int h) Sets the height of the chicken, in cmvoid
Sets the name of the chickenvoid
setWeight
(double w) Sets the weight of the chicken, in pounds
-
Constructor Details
-
Chicken
Constructs a new Chicken object with the charactistics as specified by the parameters.- Parameters:
name
- the name of the chickenh
- the height of the chicken in centimetersweight
- the weight of the chicken in pounds
-
-
Method Details
-
getHeight
public int getHeight()Returns the chicken's height, in centimeters- Returns:
- the height of the chicken, in centimeters
-
getWeight
public double getWeight()Returns the chicken's weight, in pounds- Returns:
- the weight of the chicken, in pounds
-
getName
Returns the chicken's name- Returns:
- the name of the chicken
-
feed
public void feed()Feeds the chicken, increasing the chicken's weight and height -
setName
Sets the name of the chicken- Parameters:
n
- the name of the chicken
-
setHeight
public void setHeight(int h) Sets the height of the chicken, in cm- Parameters:
h
- the height of the chicken, in cm
-
setWeight
public void setWeight(double w) Sets the weight of the chicken, in pounds- Parameters:
w
- the weight of the chicken, in pounds
-
main
Tests the Chicken class- Parameters:
args
- the command-line arguments
-