Created
September 20, 2018 01:34
-
-
Save JustenRickert/03c0a2c5ebe4322e320065f4bb4c2704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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