Home Segments Index Top Previous Next

507: Mainline

When you create a RabbitApplication instance, you need to initialize that instance such that the value of the rabbits variable is a SortedCollection instance that is sorted according to the delivery months of the rabbits. The rabbit with the earliest delivery month will always be at the front:

RabbitApplication method definition • instance 
initialize 
  rabbits := SortedCollection 
             sortBlock: 
             [:x :y | x deliveryMonth < y deliveryMonth]. 
  rabbits add: (Rabbit new deliveryMonth: 2) 

Note that initialize inserts exactly one Rabbit instance, born at month 0, into the sorted collection assigned to the rabbits instance variable.