Skip to content

Instantly share code, notes, and snippets.

@JustenRickert
Created September 20, 2018 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustenRickert/03c0a2c5ebe4322e320065f4bb4c2704 to your computer and use it in GitHub Desktop.
Save JustenRickert/03c0a2c5ebe4322e320065f4bb4c2704 to your computer and use it in GitHub Desktop.
public class RoachPopulation {
private static double initialPopulation;
RoachPopulation(double initialPopulation) {
this.initialPopulation = initialPopulation;
}
public void waitForIt() {
initialPopulation *= 2.0;
}
public void splay() {
initialPopulation *= 0.9;
}
public void print() {
System.out.println("There are " + Double.toString(initialPopulation));
}
public static void main(String[] args) {
RoachPopulation roachPop = new RoachPopulation(12.0);
roachPop.print();
roachPop.waitForIt();
roachPop.print();
roachPop.waitForIt();
roachPop.print();
roachPop.waitForIt();
roachPop.print();
roachPop.splay();
roachPop.print();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment