Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Improve the program\'s functionality by utilizing at least 5 of the concepts fro

ID: 3533876 • Letter: I

Question

Improve the program's functionality by utilizing at least 5 of the concepts from the list below. Document how the game works, including how you utilized each of the chosen concepts and what it's role is in the overall program.

List of Concepts

1. Vectors with iterators

2. Do or while loops

3. Operator overloading

4. Pointers/references

5. The heap(objects with 'new')

6. Destructor overloading

7. Constructor overloading

8. Copy constructor overloading

9. STL algorithms (sort, shuffle, etc..)

10. Private/protected data members/functions

11. Block scope

12. Function overloading

13. Multidimensional arrays

14. Functions, parameters, return values

// Guess my number

// The classic number guessing game

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

srand(static_cast<unsigned int>(time(0))); //seed random number generator

int secretNumber = rand() % 100 + 1; // random number between 1 and 100

int tries = 0;

int guess;

cout << " Welcome to Guess My Number ";

do

{

cout << "Enter a guess: ";

cin >> guess;

++tries;

if (guess > secretNumber)

{

cout << "Too high! ";

}

else if (guess < secretNumber)

{

cout << "Too low! ";

}

else

{

cout << " That's it! You got it in " << tries << "guesses! ";

}

} while (guess != secretNumber);

return 0;

}

Explanation / Answer

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

class RandomNumberGenerator

{

int secretNumber;

int tries;

int guess;

public:

RandomNumberGenerator()

{

tries=0;

secretNumber=randomNumber(100);

}

int randomNumber(int max)

{

return (rand() % max + 1); // random number between 1 and 100

}

void guessprocedure()

{

cout << " Welcome to Guess My Number ";

do

{

cout << "Enter a guess: ";

cin >> guess;

++tries;

if (guess > secretNumber)

{

cout << "Too high! ";

}

else if (guess < secretNumber)

{

cout << "Too low! ";

}

else

{

cout << " That's it! You got it in " << tries << "guesses! ";

}

} while (guess != secretNumber);

}

};

int main()

{

RandomNumberGenerator rng;

rng.guessprocedure();

return 0;

}