#include "GuessTheNumberRoom.h" #include #include using namespace std; // I modified this constructor to take in a mersenne twister as it // by default was using rand(), and that was always returning 4.s GuessTheNumberRoom::GuessTheNumberRoom(mt19937& mt) { cout << "GuessTheNumberRoom() called" << endl; mRoomName = "Guess The Number Room"; uniform_int_distribution numberDist(0, 20); _secretNumber = numberDist(mt); } GuessTheNumberRoom::~GuessTheNumberRoom() { cout << "~GuessTheNumberRoom() called" << endl; } bool GuessTheNumberRoom::escapeTheRoom() { int guess; uint8_t guesses_used = 0; while (guesses_used < 5) { cout << "Please enter a guess for the number: "; cin >> guess; guesses_used++; if (guess == _secretNumber) { cout << "That number was correct!" << endl; return true; } if (guess < _secretNumber) { cout << "That guess was too low." << endl; } else { cout << "That guess was too high." << endl; } } return false; }