#ifndef GRANDCHILD_H #define GRANDCHILD_H //The 3 "motion" classes tell the grandchild how to move. #include "manual.h" #include "randomly.h" #include "immobile.h" //The 3 "rank" classes tell the grandchild its position in the food chain. #include "herbivore.h" #include "carnivore.h" #include "inert.h" //MOTION must be a class derived from class wabbit implementing the decide //member function (and maybe the punish member function). //RANK must be a class derived from class wabbit implementing the hungry and //bitter member functions. //The constructor of the grandchild calls the constructors for the grandparent, //the mother, and the father. template class grandchild: public MOTION, public RANK { public: grandchild(const terminal& init_t, unsigned init_x, unsigned init_y): wabbit {init_t, init_x, init_y, C}, MOTION {init_t, init_x, init_y, C}, RANK {init_t, init_x, init_y, C} { } }; //The template class grandchild lets us mix and match various combinations of //motions (mothers) and ranks (fathers). //With 3 motions and 3 ranks to chose from, we could easily make 3 x 3 = 9 //grandchild classes instead of just the 4 below. //Dangerous grandchildren have uppercase names ('W', 'M'). using rabbit = grandchild; using wolf = grandchild; using boulder = grandchild; using landmine = grandchild; //etc. #endif