i am doing a problem from an obselete book.i dont know what are the attributes and functions of the base class and the derived classes!it is named forest fire simulation and i am also not find any example relating to it.Can someone ponder it?
it is given something like:
W G G A R R R R
T A Gr T W W Gr T
T W G T T W A A
R R T T A Gr W W
Now G stands for Grass, R for Rock, T for tree, W for water, Gr for Ground and A for an animal.
All of them inherit from the base class Location. Hence maintain a two dimensional array of Location pointers which may point to any of the above mentioned entities. Then you have to randomly generate a fire. Remember a fire can only happen in only the green areas i.e. Grass, or Trees. A grass can catch fire with the probability of 0.75 and the trees can catch fire with the probability of 0.5. Trees turn into ground after 3 time intervals. And grass turn into ground after 2 time intervals. Water, Rock and Ground cannot catch fire and neither the Animals can (unless u believe in spontaneous combustion). After the fire starts (hopefully) then simulate the spread of fire in the forest after each time interval. If there is a fire in the corresponding location then besides the rock, water or the ground, the grass or trees or animals can also catch fire. But the animals will try to run in the opposite direction. The can only be safe if they reach the rock or the ground or the water. Then define a new class RA or GA or WA for Rock-animal or Ground-Animal or Water-animal respectively. These cannot catch fire (obviously). An animal can catch fire if surrounded by it with probability 0.3.