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

Another question on Engineering

question
Engineering, 03.07.2019 14:10
Amass of 1.5 kg of air at 120 kpa and 24°c is contained in a gas-tight, frictionless piston-cylinder device. the air is now compressed to a final pressure of 720 kpa. during the process, heat is transferred from the air such that the temperature inside the cylinder remains constant. calculate the boundary work input during this process.
Answers: 2
question
Engineering, 04.07.2019 12:10
On a average work day more than work place firs are reorted
Answers: 1
question
Engineering, 04.07.2019 18:10
Ajournal bearing has a journal diameter of 3.250 in with a unilateral tolerance of 20.003 in. the bushing bore has a diameter of 3.256 in and a unilateral tolerance of 0.004 in. the bushing is 2.8 in long and supports a 700-lbf load. the journal speed is 900 rev/min. find the minimum oil film thickness and the maximum film pressure for both sae 20 and sae 20w-30 lubricants, for the tightest assembly if the operating film temperature is 160°f. a computer code is appropriate for solving this problem.
Answers: 3
question
Engineering, 04.07.2019 18:10
Atmospheric air has a temperature (dry bulb) of 80° f and a wet bulb temperature of 60° f when the barometric pressure is 14.696 psia. determine the specific humidity, grains/lb dry air. a. 11.4 c. 55.8 d. 22.5 b. 44.1
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
Questions on the website: 13722359