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, 04.07.2019 18:10
Aflywheel accelerates for 5 seconds at 2 rad/s2 from a speed of 20 rpm. determine the total number of revolutions of the flywheel during the period of its acceleration. a.5.65 b.8.43 c. 723 d.6.86
Answers: 2
question
Engineering, 04.07.2019 19:10
An engine, weighing 3000 n, is supported on a pedestal mount. it has been observed that the engine induces vibration into the surrounding area through its pedestal at the maximum operating speed. determine the stiffness of the dynamic vibration absorber spring in (n/m) that will reduce the vibration when mounted on the pedestal. the magnitude of the exciting force is 250 n, and the amplitude of motion of the auxiliary mass is to be limited to 2 mm note: in this question type-in right numbers, no decimals, no fractions, no unit. approximate to right number if needed
Answers: 3
question
Engineering, 04.07.2019 19:20
Ashielded metal arc-welding operation is accomplished in a work cell by a fitter and a welder. the fitter takes 5.5 min to load components into the welding fixture at the beginning of the work cycle, and 1.5 min to unload the completed weldment at the end of the cycle. the total ength of the weld seams 1200 mm, and the travel speed used by the welder averages 300 mm/min. every 600 mm of seam length, the welding stick must be changed, which takes 0.8 min. while the fitter is working, the welder is idle (resting): and while the welder is working the fitter is idle. (a) determine the average arc-on time as a fraction of the work cycle time. (b) how much improvement in arc-on time would result if the welder used flux-cored arc welding (manually operated), given that the spool of weld wire must be changed every 10 weldments, and it takes the welder 5.0 min to accomplish the change? (c) what are the production rates for these two cases (weldments completed per hour)? attach your work and solutions.
Answers: 1
question
Engineering, 06.07.2019 02:30
In a unit cell of fcc structure, indicate the position of one of the tetrahedral interstitial sites by plotting the corresponding tetrahedron. do the same for one of the octahedral interstitial sites (in a separate fcc unit cell). mark the positions of all the tetrahedral and octahedral interstitial sites in the unit cells. how many equivalent tetrahedral sites and how many equivalent octahedral sites are contained in a fcc unit cell, respectively. what is the coordination number for a tetrahedral site and what is the coordination number for an octahedral site?
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
Social Studies, 17.03.2020 00:05
Questions on the website: 13722367