#ifndef RANDOMLY_H #define RANDOMLY_H #include "wabbit.h" #include class randomly : virtual public wabbit { public: randomly(const terminal& t, unsigned x, unsigned y, char c) : wabbit(t, x, y, c) {} virtual void move() override { int dx = rand() % 3 - 1; int dy = rand() % 3 - 1; unsigned new_x = x + dx; unsigned new_y = y + dy; if (!wabbit::get(new_x, new_y)) { t->put(x, y, ' '); x = new_x; y = new_y; t->put(x, y, c); } } }; #endif