// PROBLEM 11 - page 878 of the Savitch Textbook #ifndef WORLD_H #define WORLD_H #include #include #include #include #include using namespace std; const int WORLDSIZE = 20; const int INITIALANTS = 100; const int INITIALBUGS = 5; const int DOODLEBUG = 1; const int ANT = 2; const int ANTBREED = 3; const int DOODLEBREED = 8; const int DOODLESTARVE = 3; // Forward declaration of Organism classes so we can reference it // in the World class class Organism; class Doodlebug; class Ant; #include "Organism.h" //#include "Ant.h" //#include "Doodlebug.h" // ========================================== // The World class stores data about the world by creating a // WORLDSIZE by WORLDSIZE array of type Organism. // NULL indicates an empty spot, otherwise a valid object // indicates an ant or doodlebug. To determine which, // invoke the virtual function getType of Organism that should return // ANT if the class is of type ant, and DOODLEBUG otherwise. // ========================================== class World { friend class Organism; // Allow Organism to access grid friend class Doodlebug; // Allow Organism to access grid friend class Ant; // Allow Organism to access grid public: World(); ~World(); Organism* getAt(int x, int y); void setAt(int x, int y, Organism *org); void Display(); void SimulateOneStep(); private: Organism* grid[WORLDSIZE][WORLDSIZE]; }; #endif