Class Chicken
java.lang.Object
Chicken
A Java class that represents a Chicken. The state of the chicken is
its name, height and weight. There is also a static variable
representing the name of the farm that the Chickens are on.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfeed()Feeds the chicken, increasing the chicken's weight and heightintReturns the chicken's height, in centimetersgetName()Returns the chicken's namedoubleReturns the chicken's weight, in poundsstatic voidTests the Chicken classvoidsetHeight(int h) Sets the height of the chicken, in cmvoidSets the name of the chickenvoidsetWeight(double w) Sets the weight of the chicken, in pounds
-
Constructor Details
-
Chicken
Create a new Chicken object with the charactistics as specified by the parameters.- Parameters:
name- the name of the chickenheight- the height of the chicken in centimetersweight- the weight of the chicken in pounds
-
Chicken
public Chicken(int height, double weight) Default name: "Bubba"; height and weight specified by parameters- Parameters:
height- 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
-