Hi everyone! I'm new here this is my first post and woe is me its a call to anyone willing to help me! I'm in an introduction course to java at school and I have programed a little in the past, but nothing to write home about. Today my instructor assigned a program and I have typed up the skeleton for it, and now I am just staring at my compiler watching the cursor blink I honestly have no clue where to go from here
We aren't very far into java yet so I can't use any loops or arrays or any of the fancies. I basically just have if statements.
here is the assignment:
Write a computer program to simulate the growth of a rabbit population in New Zealand. The rules that govern the population are as follows: Start with n pairs of rabbits of different sexes. The rabbits are able to mate at age of one month. A month later, each female produces two new rabbits. The probability that a new born rabbit is a female is the same as the probability that the rabbit is a male. You may assume that the rabbits never die and that the female always produce two new rabbits every month from the second month on. Your program will provide the software for observing the rabbit population in m months after the n pairs of rabbits are introduced to the island in New Zealand.
Your program should include two classes, RabbitPopulation and TestRabbitPopulation. The RabbitPopulation class should have two constructors. One "default" constructor will set the initial population to be a pair of baby rabbits that are less than one month old (one female and one male). The second constructor will set the population to include n pairs of baby rabbits (n female and n male). The value of n is to be passed through the caller of the constructor. The RabbitPopulation class should include at least five methods, waitAMonth that waits a month (the sex of any new born in the month to be determined by a random number, use Math.Random), getFemaleBabyRabbits that returns the number of female baby rabbits, getMaleBabyRabbits that returns the number of male baby rabbits, getFemaleAdultRabbits that returns the number of female adult rabbits that is at least one month old, and getMaleAdultRabbits that returns the number of male adult rabbits.
The main method of TestRabbitPopulation class should show the growth of the rabbit population after m months. You should run your simulation for at least 3 times, each with different values of n and m. Copy your outputs for (n=1, m =10), (n=6, m=20), (n=10, m=30) to a file
and here is what i have done so far:
my RabbitPopulation class
public class RabbitPopulation
{
int babyM = 0;
int babyF = 0;
int adultM = 0;
int adultF = 0;
double love;
public RabbitPopulation()
{
}
public RabbitPopulation(int a)
{
babyM = a;
babyF = a;
}
public void waitAMonth()
{
/* this is junk doesnt do anything helpful I dont think
if (adultF>=1)
{
babyM++;
babyF++;
}
*/
}
public int getFemaleBabyRabbits()
{
return babyF;
}
public int getMaleBabyRabbits()
{
return babyM;
}
public int getFemaleAdultRabbits()
{
return adultF;
}
public int getMaleAdultRabbits()
{
return adultM;
}
}
and my tester class. the print statement there was to see if
my methods worked at all ^.^
public class testRabbitPopulation
{
public static void main(String[] args)
{
RabbitPopulation bunny = new RabbitPopulation();
System.out.println("Enter number of pairs of rabbits: ");
System.out.println(bunny.getFemaleBabyRabbits());
}
}
I'm not asking for someone to write my program just nudge me in a direction. I'm having trouble with the waitAMonth method, trying to figure out how to increase everything and use the Math.random().... thinking about it all at once makes my head hurt
so if anyone is willing to read my massive post and offer any help that would make this rabbit induced headache go away!
Thanks everyone