This assignment will involve both inheritance and composition to accomplish an i
ID: 3871928 • Letter: T
Question
This assignment will involve both inheritance and composition to accomplish an implementation of the 15-puzzle. Three classes will be used single_player_game: a class that only monitors the number of moves made in the game fifteen_board: a class that implements the board, handles logic related to determining legal moves on the board, moving, displaying the board, and determining the Manhattan distance fifteen game: a class that inherits from single player game and uses composition with respect to fifteen_board e The class headers are in the following directory on bobby: /home/williams/public/f17cs202/assignment/2 You are not to modify the headers except to do the following Add # include guards. (Not technically required for this assignment, but good practice so it is required that you do it) Add comments as appropriate Change the filenames as necessary · . . What you must do is implement the class functions and a main body. Details on the class functions are as follows: * single_player_game constructor: initialize the moves to 0 getmoves: return the # of moves set_moves: set the moves to an integer o - o fifteen_board: o constructor: initialize the board to the "solved" state of: 4 10 14 Note: 0 indicates the "blank space" 12 13 15 0 o set_board: change the board to some data (which will be input from a file) Note: the identifier board refers to the local board, to access the board member variable, use this->board display_board: display the board (using setw(5)) move: "move" the blank space on the board. For example, if we move "up" in the aforementioned solved state, 0 and 12 swap locations. Only move if the move is legal (e.g. we are not moving the 0 off the board). Return true if the move was successful return false if the move was not (e.g. it was invalid). o o Note: We are using an enum here, so you could do some logic like this if (dir = u) { … }Explanation / Answer
class Array2DWrapperDynamicN { int *ptr; int N; public: Array2DWrapper(int *ptr, int N) : ptr(ptr), N(N) {} int * operator[](int i) { return ptr + i*N; } };