Question: Answer in C + + please and give step by step code and explenation thank you You will create at least four files for this

Answer in C++ please and give step by step code and explenation thank you
You will create at least four files for this assignment: GameObject.h, Game.h, Game.cpp, Main.cpp
Create a GameObject class (declaration and implementation in GameObject.h since this class is very simple):
Protected attribute:
symbol (the symbol for the game object that gets displayed)
Public methods:
void setSymbol(char s): set the game object symbol
char getSymbol(): return the game object symbol
Create a UserPlayer class that is a child of the GameObject class (in GameObject.h):
Private attribute:
x, y (the location of the player)
Public methods:
UserPlayer(int x_=0, int, y_=0, char s ='X'): a constructor that takes up to 3 variables and doubles as a default constructor too.
void setLocation(int x_, int y_): set the attributes x, y
int getX(): return the x location
int getY(): return the y location
Create a Game class (declaration and simple implementations in Game.h while complex implementation in Game.cpp):
Private attributes (required):
width =15(the width of the game board)
height =10(the height of the game board)
gameBoard[10][15](the game board consisting of symbols). You would need to use the absolute number here (10 and 15) instead of the attributes width and height since, from a compiler point of view, these attributes are not defined until the object is completely created.
numDeadBlock =10(the number of deadly blocks in the game)
player (UserPlayer object for this game)
block (GameObject object for the empty slots)
Private attributes (optional):
numHit =0(how many times the player got hit)
deadBlockLocation[10][2](a 2D array of the location of the deadly blocks. You can hardcode this, i.e., explicitly specify the location)
Public methods (required):
Game(UserPlayer p_, GameObject b_): constructor (you may add extra parameters)
void printGameBoard(): print the game board on the screen
void playGame(): runs the game fully by asking the user for input (wasd or q to quit), moving the player if the move is valid, printing the game board after every round, checking if the user has hit a hidden deadly block. It also stops the game when the user is at the end of the board, i.e., bottom right (Hint, when this condition happens, simply write return;. This will exit the whole method). You may want to call printGameBoard() and withinBorders() methods here.
Public methods (optional):
bool withinBorders(int x, int y): check of x and y are within the game borders.
In the main function (in Main.cpp):
Create a UserPlayer object (for the player) and set its symbol.
Create a GameObject object (for empty blocks) and set its symbol.
Create a Game object.
Call the playGame method for the game object.
Enhancement (20%):
Create the deadly blocks at random locations (Hint: we did random number generation in the class). Suggestion: In the main function, write down srand((unsigned int)time(nullptr)); before you create the game. This statement tells the compiler to generate more randomized numbers.
Make what you print in the console colorful as shown in the game play.
Notes
Make sure declarations and simple implementations are done in header files (.h) while complex implementations are done in cpp files (.cpp).
Make sure to use the attributes/variables rather than hardcoding. For example, don't use the numbers 10 and 15 when printing the boardGame array. Rather, use the the attributes/variables that hold the board dimensions.
Add description for your classes/methods.
You may add other public/private attributes and methods and even classes. You may do other things in your main function (e.g., ask the user for their name).
You may change the value of the attributes. The ones I gave you just make a simple yet challenging game.
You may choose not to use a 2D array in the game.
You may use any built-in library.
The optional attributes/methods are ones I used for my solutions to make my code more concise. You may find them useful.
You may add extra features (e.g., add walls that block the player).
You can use (std::cin) to get the user input OR you can use (_getche() from #include ) to avoid having the user pressing enter after printing the direction letter (the function reads one character only).
You may NOT CHANGE the structure. The goal of the assignment is to have multiple classes (at least 3), implement inheritance, and use an object from a class we built as an attribute in another class. Moreover, you must get used to distributing code across multiple files.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!