#include //for the srand function and EXIT_SUCCESS #include //for the time function #include "terminal.h" #include "wolf.h" #include "rabbit.h" using namespace std; int main() { srand(static_cast(time(0))); const terminal term('.'); const unsigned xmax = term.xmax(); const unsigned ymax = term.ymax(); wolf w(term, xmax / 3, ymax / 2); rabbit a[] = { rabbit(term, xmax * 2 / 3, ymax / 4), rabbit(term, xmax * 2 / 3, ymax / 2), rabbit(term, xmax * 2 / 3, ymax * 3 / 4), rabbit(term, xmax * 2 / 3, ymax * 7 / 8) }; const size_t n = sizeof a / sizeof a[0]; for (;; term.wait(250)) { //250 milliseconds equals .25 seconds if (!w.move()) { break; } for (rabbit *p = a; p < a + n; ++p) { if (!p->move()) { goto done; } } } done:; term.put(0, 0, "You killed the rabbit!"); term.wait(3000); //Give user three seconds to read the message. return EXIT_SUCCESS; //Destruct rabbit, wolf, & terminal, in that order. }