• Forum
  • Jobs
  • Please help in the project solution

 
Please help in the project solution


Object Oriented Programming (45111)
Course Project

The task:
Implement a program that simulates the relationship between spiders and aunts. The
spiders and aunts live in a garden, which is represented by a regular grid of NX times NY
cells. At any time no more than one creature can be located in a cell. The garden has
periodic boundaries so that if an aunt (or spider) moves over one edge, it will re-enter onthe opposite site of the garden.

The simulation proceeds in time steps. At every time step, the aunt performs
the following actions:
 Move: An aunt randomly moves up, down, left, or right to an empty cell. Only, if
there is no empty neighboring cell, the aunt stays in its cell.
 Breed: If an aunt moves to another cell and if it has not bred during the last
AUNT_BREED time steps, it will breed. This means that a new aunt is created in
its old cell.
he spiders act according to the following rules:
 Move: If there is one or more aunt in the neighboring cells, a spider will choose
randomly one of these aunts, move to its cell and eat it. If there is no aunt in the
neighboring cells, spiders follow the same rules to move as aunts. Spiders do not
eat other spiders.
 Breed: A spider breeds in the same way as an aunt if it has not bred during the last
SPIDER_BREED time steps.
 Starve: If a spider has not eaten an aunt during the last SPIDER_STARVE time
steps, it will starve, which means that it is removed from the simulation.
Implementation
Create a class Creature which contains the data common to aunt and spiders. This class
defines two functions:
 move(): If called, the function performs the actions the Creature takes during
one time step. This function must be implemented as a virtual function.
 isSpider() const: This function should return a boolean value which is true if the
object is a Spider. It can but does not have to be a virtual function.

Derive from this base classthe classes Aunt and Spider. The parameters
AUNT_BREED, SPIDER_BREED, and SPIDER_STARVE are set by static class
functions void setBreed(int) and setStarve(int);
Furthermore, create a class Garden that stores what creatures are in which cell. Garden
should have the following member functions:
 A constructor which takes two integer arguments which determine the dimensions
of the garden.
 Accessor functions getHeight() and getWidth() (const) which return the
dimensions.
 Member functions setNumberOfSpiders(int) and setNumberOfAunt(int) that
allow to (re)set the number of creatures in the garden.
 Corresponding const accessor functions getNumberOfAunt() and
getNumberOfSpiders().
 A const member function getCell() which takes two integer argments (x, y) and
returns a (maybe const) pointer to the creature in the cell specified by the
arguments. If the cell is empty, a NULL pointer is returned.
 A member function step() which lets all creatures in the garden perform the
actions of one time step (move, breed, starve).
Finally, write a main() function which runs the simulation in a loop and shows the state
of garden on the console using '.', and '0' to represent aunt and spiders. The user might be
prompted to press Enter to advance to the next time step. Keep the main and output
functions separated from the simulation code.
Last edited on
Send me a private message or email me at [email protected]
i am quite interested with this. but may i ask, by aunt you mean a person?the sister of one's father or mother or the wife of one's uncle?
Finish your homework by yourself, PLEASE~!
Hello I can help and I interested, contact me.

[email protected]

regards
cronos
Thank you all for your interest

If you're having trouble understanding and using classes, I'd be happy to help you. Email me at: [email protected]
Topic archived. No new replies allowed.