/* Delete any other wabbit that got eaten during the move (line 30), but do not delete this wabbit. If this wabbit was eaten during the move, return false (line 34); otherwise return true. */ bool wabbit::move() { int dx; //uninitialized variables int dy; decide(&dx, &dy); if (dx and dy are both zero) { return true; } const unsigned newx = x + dx; const unsigned newy = y + dy; if (!g->term.in_range(newx, newy)) { punish(); return true; } if (wabbit *const other = g->get(newx, newy)) { const bool I_ate_him = this->hungry() > other->bitter(); const bool he_ate_me = other->hungry() > this->bitter(); if (I_ate_him) { delete other; } if (he_ate_me) { return false; //not allowed to delete myself } if (!I_ate_him) { //I bumped into a wabbit that I could neither eat nor be //eaten by. punish(); return true; } } g->term.put(x, y); //Erase this wabbit from its old location. x = newx; y = newy; g->term.put(x, y, c); //Redraw this wabbit at its new location. return true; }