/* * Keeps track of rabbit population */ public class RabbitPopulation { private int numImmatureRabbits; private int numMatureRabbits; /* * Constructs the Rabbit Population with 1 pair */ public RabbitPopulation() { this.numMatureRabbits = 2; } /* * Simulates 1 Month */ public void waitAMonth() { int tempMatureRabbits = this.numMatureRabbits; this.numMatureRabbits = this.numMatureRabbits + this.numImmatureRabbits; this.numImmatureRabbits = tempMatureRabbits; } public int getPairs() { return (this.numMatureRabbits + this.numImmatureRabbits) / 2; } }