MakeChicken2
Objective(s): Practice creating an array of objects and working with a java class.
Given the Chicken
class below, create 10 Chicken
objects stored in an array. Each object should have an age of 2.
Hint: This problem is asking you to visit your knowledge of java classes that have multiple constructors. How do you use one constructor over the other? What determines which one is called?
public class Chicken{
private double weight, age;
public Chicken(){ //the default constructor (no parameter)
weight = (int)(Math.random()*101);
}public Chicken(int param_age){ //a constructor that takes in a number
this(); //calls the default constructor
age = param_age;
}}
Type your solution
Skills Practiced:
3.A
3.C
3.D
4.A
4.B
Saved
Saved