10.5.   _____________________________295

living* next(world w) ;

};

//   ()
class empty : public living {
public:

empty(int r, int c) { row = r; column = c; }

state who() { return EMPTY; }

living* next(world w) ;

};

 ,        
    ,    -
.  ,       ,  
  next ().

   .      , 
,  ,      (   -
  ,       ):

living* grass::next(world w)

{

int sum[STATES];

sums(w, sum) ;

if (sum[GRASS] > sum[RABBIT])    // 

return (new grass(row, column));

else

return (new empty(row, column));

}

   ,       -
 DRAB,   ,       .

living* rabbit::next(world w)

{

int sum[STATES];

sums(w, sum) ;

if (sum[FOX] >= sum[RABBIT] )    // 

return (new empty(row, column));

else if (age > DRAB)             // 

return (new emptyfrow, column));

else

return (new rabbit(row, column, age + 1));

'i

       :

living* fox::next(world w)
{

int sum[STATES];