CS 1063 Project 1:
Designing and Implementing a Class
The RoachPopulation Class
Objectives
- Construct and use Objects
- Design the public interface of a class
- Determine the instance variables necessary for a class
- Implement the shell of a class using stubs with comments
- Implement constructors
- Implement simple methods
- Access instance fields and local variables
Hand-in Requirements
- Public Interface as a word document
- RoachPopulation.java
- RoachPopulationTest.java
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