package class7_3_Yogurt; // MSOE. Dr. Yoder. 13 October 2015. public class Incubator { // 100 million cultures per gram (NYA - Nat. Yogurt Assoc.) // 200 g/cup (random web search) // 200 g/cup * 100 million cult./gram = 20 billion cultures / 1 cup private final long BACTERIA_PER_CUP_STARTER = 20_000_000_000L; public final double GROWTH_RATE_PER_HOUR = 0.05; private long numBacteria; /** * Add starter to the culture. * Adds the number of bacterium in the given volume of starter * @param starterCups amount of starter, in cups, to add. */ public void addStarterCups(double starterCups) { // Point B long newBacteria = (long)(starterCups * BACTERIA_PER_CUP_STARTER); // Point C numBacteria += newBacteria; // Point D } /** * @return the integer number of bacteria cells in the incubator */ public long getNumBacteria() { // Point F return numBacteria; } /** * Simulate one hour of incubation. * Increase the number of bacterium in the culture by the growth rate. * (Relative to the original number of bacteria) */ public void incubateOneHour() { numBacteria = numBacteria + (long)(numBacteria * GROWTH_RATE_PER_HOUR); } /** * Exercise: What is the state of the program at HERE 2? * @param other a mystery... */ public void mystery(Incubator other) { long total; // HERE 1 total = this.numBacteria + other.numBacteria; this.numBacteria = total/2; other.numBacteria = total/2; // HERE 2 } }