Difference between revisions of "If a rabbit is contained within a warren, create a den class for foxes"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "== Den Foxes ==")
 
Line 1: Line 1:
 
== Den Foxes ==
 
== Den Foxes ==
 +
This is unlikely to be a question you need to program, the detail and number of changes make it impractical in the time you have. You can easily create a new class for a Den by copying the warren class and edit it to become a den, ie change all references from Warren to Den, and change all references from Rabbit to Fox.
 +
 +
[[File:Warren to den.gif]]
 +
 +
[[File:Rabbit to fox.gif]]
 +
 +
However, a location can only contain a fox and or a warren. You will therefore need to remove the Fox declaration and instead declare a Den. Therefore a location can only contain a Den or Warren. In the simulation class AdvanceTimePeriod, FoxesEatRabbitsInWarren at the moment works for if fox at location is not null, however this will need to be changed so it works if Den at location is not null, and then for every fox in the den at that location.
 +
 +
Also how the foxes are created will need to be changed so that they are created by the Den and not by the simulation. Also when a fox reproduces it increments a variable called NewFoxCount. This is then used to randomly position the new foxes, this would need to change so that the den

Revision as of 08:58, 12 June 2017

Den Foxes

This is unlikely to be a question you need to program, the detail and number of changes make it impractical in the time you have. You can easily create a new class for a Den by copying the warren class and edit it to become a den, ie change all references from Warren to Den, and change all references from Rabbit to Fox.

Warren to den.gif

Rabbit to fox.gif

However, a location can only contain a fox and or a warren. You will therefore need to remove the Fox declaration and instead declare a Den. Therefore a location can only contain a Den or Warren. In the simulation class AdvanceTimePeriod, FoxesEatRabbitsInWarren at the moment works for if fox at location is not null, however this will need to be changed so it works if Den at location is not null, and then for every fox in the den at that location.

Also how the foxes are created will need to be changed so that they are created by the Den and not by the simulation. Also when a fox reproduces it increments a variable called NewFoxCount. This is then used to randomly position the new foxes, this would need to change so that the den