Aide à mon projet

Fermé
fatized - Modifié par fatized le 31/03/2011 à 20:11
choubaka Messages postés 39409 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 24 décembre 2024 - 31 mars 2011 à 20:03
Bonjour, J'ai besoint d'une orientation des conseils pour effectuer mon projet car j'ai pas une grande experience a faire des programme pareil!.

The goal of this project is to implement a simplifed model of a forest.
A forest is a society where animals and plants live toghether. We suppose
that a forest contains a set of organisms. An organism is either an animal,
or a plant. An animal can be an eagle, a canary, a lion or a zebra.
 Write the classes corresponding to the defined objects. Use inheritence
to relate the concepts. Pay attention to the properties of the classes.
Organisms have age and lifetime.
 Add a bool to organism defining if the organism is alive. An organism
is alive when it is created. Add a die() method in organism which will
set the alive state to false. Add a getter for this state.
 Add a constructor to the organism class, which takes and sets the
lifetime of the organism. The alive bool is set to true and the age is
set to zero.
 Add a constructor to the animal class which takes the lifetime and
passes it to its superclass (organism). The constructor does not do
anything.
 Add constructors to the subclasses (lion, plant, eagle, ...). Each of
them calls (using the superclass constructing syntax) the constructor
of its superclass passing its speci ed lifetime. For example lion calls
the constructor of the animal passing 10 as lifetime, and a plant calls
the constructor of organism passing 3 as lifetime.
 Add a pure virtual char getName() method to organism which return
the character corresponding to the organism. Override the method in
all subclasses and implement them to return the first character of the
class name (example: the lion class returns L, ...)
 Add a void print() method to the organism class which gets the name
(by calling the getName method) and prints it to the screen.
1
 Organisms eat. Eagles eat canaries. Canaries and zebra eat plants.
Lions eat zebra. Add a virtual void method void eat(Organism* or-
ganism) to organism class which takes a pointer to an organism. Add
this methods to all subclasses except plant and animal. Implement the
eat method of each class according to the above eating relations: The
parameter organism dies if it can be eaten by the organism. The or-
ganism dies if it can not eat the parameter organism. Use the getName
method to and the name of the organism.
 Organisms grow. Add a grow method to the organism class which
increases the age of the organism. This method must also verify if the
lifetime is reached, in which case the organism dies (by calling the die
method).
 Create the forest class which contains a dynamic array of organism
pointers (it is defined by: Organism**). The forest must be populated
by a random set of organisms at construction. Add a constructor which
creates the array and fills each element of the array by a random new
organism (a lion, an eagle, or ...)
 Create a destructor for the forest class which deletes all created vari-
ables.
 Add a print() method to the forest, which prints the name of all alive
organisms (example: LEPPE)
 Add a start() method which simulates the forest life in an in nite loop.
At each iteration:
{ The alive organisms grow.
{ The alive animals eat. For each alive organism the forest calls its
eat method passing another randomly chosen alive organism as
parameter.
{ The loop terminated when there is no more alive organism.
Test the forest. Create a forest and call the start() method in the main
method.

A voir également:

1 réponse

choubaka Messages postés 39409 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 24 décembre 2024 2 104
31 mars 2011 à 20:03
1