CMPT 126 - Harbour Centre - Fall 2006
Home  
Assigned Readings  
Examples  
Labs  
Assignments  
References  
Gradebook  
 
  This lab will focus on object-oriented design. Consider the following specification when answering the questions below.

Biologists often use computer models to simulate behaviour of animals. Computer models are specific descriptions of behaviour that can be implemented in a computer program. The programs can be run to test assumptions against real data and used to generate new hypotheses that can be tested experimentally.

In Individual-Based Models, many individual animals are simulated separately. Our model will simulate (let's say) Zebras grazing.

The zebra's (rectangular) range will be divided into a grid of small habitats. Each zebra will be in one of the habitats. In each time unit, a zebra can move to an adjacent square in one of the four compass directions (north, south, east, west), but can't move off the edge of the grid.

In each of the habitats, there is a certain amount of food (grass). Of course, as zebras eat the grass, it disappears. The grass does slowly regrow as time passes.

When zebras eat, they gain "energy". If they don't eat for long enough, they burn all of their energy reserves and starve to death.

Zebras decide which direction to move (or to stay where they are) based on the amount of food available, and the number of other zebras in that it will have to share the food in that location with. The zebra always makes the best decision based on what it can see in the adjacent habitats.

As with any model, there will be many parameters that can be adjusted to tune the way the system works. For example, the amount of grass that a single zebra eats. It may be necessary to change these values frequently, so the design should allow for this.

Answer these questions using that problem statement.

  1. Identify the key nouns in the problem statement above, and come up with a list of classes that would be used in an implementation of the above program. Put your answer in a text file named design.txt.
  2. For each class, add a brief description of its responsibilities. Each description should be at most a couple of sentences. Add this to design.txt.
  3. Create a text file named time.txt. In it, indicate how long it took you to complete this lab exercise.

When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server. Remember to include an additional class for testing your work.