I need help as soon as possible please hs to with arrays.
import java.util.Random;
publicclass AviarySimulator
{
// Instance variables
private Aviary aviary;
privateint numberOfDays = 0;
private Random r;
publicvoid simulateDay(int amtFeed)
{
//a new Day
numberOfDays++;
System.out.println("**************************");
System.out.println ("Day : " + numberOfDays);
if(!aviary.isEmpty())
{
// Ask the cage to supply its budgie object
Budgie theBudgie = aviary.getBudgie();
/* Check there really is a Bird in the cage. null means that there is no
* bird object assigned to the myBudgie variable in class cage.
*/
if(theBudgie !=null)
{
// Code moved from below. PR
// Budgie gets older because a day has gone by.
theBudgie.incAge();
// Budgie exercises every day PR
theBudgie.exercise(DAILY_EXERCISE);
// Feed the budgie
// To avoid feeding nothing, check that food is given PR
// Also rejects negative feed!
if(amtFeed > 0)
{
theBudgie.eat(amtFeed);
System.out.println("Just been fed " + amtFeed +" grams of bird seed");
}
// Check if the budgie is still alive
if(theBudgie.isDead())
{
System.out.println(theBudgie.getName() +" just died...sob");
System.out.println("Here lies " + theBudgie.getName() +" this budgie was much loved by its " +
theBudgie.getNumEggsLaid() +" eggy ofspring");
aviary.removeBudgie();
}
// If alive is it overweight?
elseif(theBudgie.isObese())
{
System.out.println(theBudgie.getName() +" is obese it needs some exercise");
theBudgie.exercise(10);
}
else// Budgie is alive and not overweight
{
System.out.println(theBudgie.toString());
// The budgie gets a day older
// theBudgie.incAge(); // Moved to above PR
// The budgie may lay an egg
if(theBudgie.layEgg(r))
{
System.out.println(theBudgie.getName() +" has just laid an egg ");
System.out.println("The egg has been removed from the cage for artificial incubation \n"
+"and will be adopted out after hatching");
}
}
}
}
else// No budgie in the cage
{
System.out.println("The cage is empty");
}
}
//--
/**
* Simulate several days without food.
* @param numDays, the length of the simulation
*/
publicvoid simulateDays(int numDays)
{
for(int i = 0; i < numDays; i++)
{
simulateDay(0);// PR
}
}
//--
/**
* Simulate several days with food.
* @param numDays, the length of the simulation
* @param amtFeed, the amount of budgie food in grammes
*/
publicvoid simulateDays(int numDays,int gmsSeed)
{
for(int i = 0; i < numDays; i++)
{
simulateDay(gmsSeed);
}
}
//--
}
This code is supposed to be compatible with this code:
public Budgie(String name,boolean female)// Added gender PR
{
// Initialise instance variables
age = 0;
colour ="green";// Default colour
canTalk =false;// Cannot talk yet, can only go "cheep"
// Quotes removed PR
budgiesWords ="cheep";
weight = 25;// In healthy weight range
bIsFemale = female;// PR
water = 10;
// Record supplied name
this.name = name;
}
//--
/**
* Teaches a budgie to talk
* @param phrase - what the budgie can say
*/
publicvoid teachToTalk(String phrase)
{
// Ignore an empty string
if(phrase !="")
{
// Budgie can now talk
canTalk =true;
budgiesWords = phrase;
}
}
//--
/**
* Increments a budgie's age by a day
*/
publicvoid incAge()
{
age++;
}
//--
/**
* The budgie is dead if it is too old or too fat or starved or too thirsty.
*/
publicboolean isDead()
{
return (diedOfOldAge() || diedFromOverFeeding() || isStarved() || diedOfThirst());
}
//--
/**
* The budgie is too old if it is older than the budgie's maximum age.
*/
publicboolean diedOfOldAge()
{
return (age > MAX_AGE);
}
//--
/**
* The budgie is too thirsty if it is has less than 10mls of water.
*/
publicboolean diedOfThirst()
{
return (water < MIN_DRINK);
}
//--
/**
* The budgie is too heavy to live if it is more than double a
* budgie's sensible weight limit.
*/
publicboolean diedFromOverFeeding()
{
return (weight >= TOO_FAT*2);
}
//--
/**
* The budgie is obese if it is more than a budgie's sensible
* weight limit.
*/
publicboolean isObese()
{
return (weight >= TOO_FAT);
}
//--
/**
* The budgie is starved if it is less than a budgie's sensible
* minimum weight.
*/
publicboolean isStarved()
{
return (weight <= TOO_THIN);
}
//--
/**
* The budgie has been fed. It will put on weight.
* @param gmsOfBirdFeed, the amount of food eaten in grammes
*/
publicvoid eat(int gmsOfBirdFeed)
{
// Convert to gms fat
double fat = gmsOfBirdFeed/10.0;
weight = weight + fat;
}
//--
/**
* The budgie has drunk.
* @param mlsofwater, the amount of water drunk in mls
*/
publicvoid drink(int mlsOfWater)
{
water = mlsOfWater;
}
//--
/**
* The budgie has done some exercise. It will lose weight.
* @param minutesOfExercise, the time of the exercise
*/
publicvoid exercise(int minutesOfExercise)
{
double weightLoss = minutesOfExercise * 0.1;// For each minute lose 0.1 gms fat
weight -= weightLoss;
System.out.println("Budgie exercising for " + minutesOfExercise +" minutes, has lost " + weightLoss +" grammes in weight." );
}
//--
/**
* The budgie may lay an egg. Only adults can lay eggs.
* @param rnd, a random object
*/
publicboolean layEgg(Random rnd)
{
boolean bLaying =false;// default
// Only hens can lay eggs // PR
if(bIsFemale)
{
int probability = rnd.nextInt(10);
// Random chance that it will lay
// Added that cannot lay if last egg laid yesterday PR
if((probability >= 5) && (age > ADULT_AGE ) && (age - lastEgg != 1))
{
// Can only lay eggs if a grown-up
numEggsLaid++;
bLaying =true;
lastEgg = age;// Laid an egg today PR
}
}
return bLaying;
}
//--
/**
* The budgie talks - display its words.
*/
publicvoid talk()
{
System.out.println(budgiesWords);
}
//--
/**
* Change the colour of the budgie.
* @param newColour, new value of budgie's colour
*/
publicvoid setColor(String newColour)
{
colour = newColour;
}
//--
/**
* Return the colour of the budgie.
* @return budgie's colour
*/
public String getColour()
{
return colour;
}
//--
/**
* Output the budgie's details.
* @return A string containing all details of the budgie
*/
public String toString()
{
String msg ="Budgie " + name +" ";
if(canTalk)
{
msg +="can talk it says ";
}
else
{
msg +="can not talk it just makes the sound ";
}
msg +="'" + budgiesWords +"'";
msg +="\n";
msg +=" Its colour is : " + colour;
msg +="\n Its age is : " + age +" days.";
return msg;
}
//--
/**
* Return the number of eggs the budgie has laid.
* @return eggs laid by budgie
*/
publicint getNumEggsLaid()
{
return numEggsLaid;
}
//--
/**
* Return the budgie's age.
* @return age of budgie
*/
publicint getAge()
{
return age;
}
//--
/**
* Return the budgie's name.
* @return name of budgie
*/
public String getName()
{
return name;
}
//--
/**
* Return the budgie's gender.
* @return true if budgie is female
*/
publicboolean isFemale()
{
return bIsFemale;
}
//--
}
But everytime Itry to compile it highlightthis bit in the simulator:
Budgie theBudgie = aviary.getBudgie();[code]
With an error message:
getBudgie in Aviary cannot be applied to ()
Im sorry for the long post please help would be most apreciated.

