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 23:20
Two technicians are discussing the intake air temperature (iat) sensor. technician a says that the computer uses the iat sensor as a backup to the engine coolant temperature (ect) sensor. technician b says that the powertrain control module (pcm) will subtract the calculated amount of fuel if the air measures hot. who is correct
Answers: 3
question
Engineering, 04.07.2019 18:20
Aquick transition of the operating speed of a shaft from its critical speed will whirl amplitude. (a) increase (b) limit (c) not affect (d) zero
Answers: 2
question
Engineering, 04.07.2019 18:20
Determine the damped natural frequencies and the steady state response of a decoupled damped forced two degrees of freedom system. 10รค1 + 2q1 20q1 10 cos t; 10q2 +4q2 + 40q2 10 cos t
Answers: 3
question
Engineering, 04.07.2019 19:10
The sum of the normal stresses does not change as the stress state rotates through an angle. a)-trune b)- false
Answers: 2
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
question
Medicine, 08.12.2020 23:20
question
Mathematics, 08.12.2020 23:20
question
Mathematics, 08.12.2020 23:20
question
Health, 08.12.2020 23:20
question
Mathematics, 08.12.2020 23:20
question
Mathematics, 08.12.2020 23:20
question
English, 08.12.2020 23:20
question
Arts, 08.12.2020 23:20