subject
Engineering, 09.12.2019 17:31 TV865432

Write a class named fboard for playing a game, where player x is trying to get her piece to row 7 and player o is trying to make it so player x doesn't have any legal moves. it should have: an 8x8 array of char for tracking the positions of the pieces. a data member called gamestate that holds one of the following values: x_won, o_won, or unfinished - use an enum type for this, not string (the enum definition should go in board. hpp, before the class, not inside it).data members to keep track of where the x piece is. a default constructor that initializes the array to empty (you can use whatever character you want to represent empty). it should then put four o pieces on row 7, in columns 0, 2, 4, and 6. it should put an x piece on row 0, column 3. it should also initialize the other data members. a method called getgamestate that just returns the value of gamestate. a method called movex that takes as parameters the row and column of the square to move to. if the desired move is not allowed, or if the game has already been won, it should just return false. otherwise it should make the move and return true. a piece belonging to x can move 1 square diagonally in any direction. a piece is not allowed to move off the board or to an occupied square. if x's move gets her piece to row 7, gamestate should be set to x_won. a method called moveo that takes as parameters the row and column to move from, and the row and column to move to. if the first pair of coordinates doesn't hold o's piece, or if the desired move is not allowed, or if the game has already been won, it should just return false. othewise it should make the move and return true. a piece belonging to o can move 1 square diagonally, but the row cannot increase, so any o piece has at most two available moves. for example, if player o has a piece at (5, 2), it could move to (4, 1) or (4, 3), but not (6, 1) or (6, 3). it is not allowed to move off the board or to an occupied square. if o's move leaves no legal move for x, gamestate should be set to o_won. you do not need to track whose turn it is. either move method can be called multiple times in a row. it doesn't matter which index of the array you consider the row and which you consider the column as long as you're consistent. feel free to add private functions if you want. you may also find it useful to add a public print function to with debugging. do not access the array out of bounds. make sure values are in bounds before using them to index into the array.

ansver
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 14:10, aliceohern
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
image
Engineering, 04.07.2019 18:10, siri5645
At 12 noon, the count in a bacteria culture was 400; at 4: 00 pm the count was 1200 let p(t) denote the bacteria cou population growth law. find: (a) an expression for the bacteria count at any time t (b) the bacteria count at 10 am. (c) the time required for the bacteria count to reach 1800.
Answers: 1
image
Engineering, 04.07.2019 18:10, Larkinlover703
Items are similar to the free issue items, but their access is limited. (clo5) a)-bin stock items free issue b)-bin stock controlled issue c)-critical or insurance spares d)-rebuildable spares e)-consumables
Answers: 1
image
Engineering, 04.07.2019 18:10, salazjlove
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
You know the right answer?
Write a class named fboard for playing a game, where player x is trying to get her piece to row 7 an...

Questions in other subjects: