CS 1063  Project 1:  Designing and Implementing a Class

The RoachPopulation Class


Objectives

Hand-in Requirements

Details

       Implement a class RoachPopulation that simulates the growth of a roach population.  The constructor takes the size of the initial roach population as a double.  The waitTime method simulates a period in which the population doubles.  The spray method simulates spraying with insecticide, which reduces the population by 10%.  The getRoaches method returns the current number of roaches.  Implement the class and a test program that simulates a kitchen that starts out with 10 roaches.  wait, spray, print the roach count. Repeat three more times.  Be sure to furnish a toString method for printing the roach count.

Last revision: August 26, 2004 at 10:55 pm