Home Segments Index Top Previous Next

506: Mainline

Next, you are ready to define a class, RabbitApplication, to help you keep track of the simulated rabbit population.

There will be just one RabbitApplication instance, and, from the definition of the RabbitApplication class, you see that the one RabbitApplication instance contains just one instance variable: rabbits. The rabbits instance variable determines the state of the RabbitApplication instance.

RabbitApplication class definition 
Object subclass: #RabbitApplication 
  instanceVariableNames: 'rabbits' 
  classVariableNames: '' 
  poolDictionaries: '' 

Two RabbitApplication instance methods are to be defined. One, the initialize method, initializes rabbit simulations; the other, the tickTo: method, executes rabbit simulations for a specified number of steps.