Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please. Write a class called GBoard that represents the board for a game that is like tic-tac-toe, but on a larger scale. Instead of

C++ please.
Write a class called GBoard that represents the board for a game that is like tic-tac-toe, but on a larger scale. Instead of a 3x3 board, it is played on a 15x15 board, and instead of 3 in a row, each player is trying to get 5 in row.
The class should have two data members - a 2D array of char that represents the board, and an enum variable called gameState that holds one of the four following values: X_WON, O_WON, DRAW, or UNFINISHED - use an enum for this, not strings (the enum definition should go in GBoard.hpp, before the class, not inside it).
It should have a default constructor that initializes all elements of the array to being empty (you can use whatever character you want to represent that a square is empty), and initializes the gameState to UNFINISHED.
It should have a method called getGameState that returns the value of gameState.
It should have a method called makeMove that takes as parameters an int for the row, an int for the column, and a char for the player. The row and column will be in the range 0-14. The player will be either 'x' or 'o'. This method should return false if the square is already occupied or the game had already finished. Otherwise it should add the move to the board, update the gameState, and return true. Be careful to not access your array out of bounds - including in the condition of an if statement or loop.
It's not required, but you'll probably find it useful for testing and debugging to have a method that prints out the board.
Whether you think of the array indices as being [row][column] or [column][row] doesn't matter as long as you're consistent.
Your class only represents the board, it doesn't actually allow two players to play the game. Other code (that you don't have to write) would use your Board class to make that happen.
The files must be named: GBoard.hpp and GBoard.cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

your team is deciding whether to sell customer data

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago