Engineering
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.

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, abdirahmansoloman
Air is to be cooled in the evaporator section of a refrigerator by passing it over a bank of 0.8-cm-outer-diameter and 0.4-m-long tubes inside which the refrigerant is evaporating at -20°c. air approaches the tube bank in the normal direction at 0°c and 1 atm with a mean velocity of 4 m/s. the tubes are arranged in-line with longitudinal and transverse pitches of sl- st 1.5 cm. there are 30 rows in the flow direction with 15 tubes in each row. determine (a) the refrigeration capacity of this system and (b) pressure drop across the tube bank. evaluate the air properties at an assumed mean temperature of -5°c and 1 atm. is this a good assumption?
Answers: 1
image
Engineering, 04.07.2019 18:10, Fahaddie
The thermal expansion or contraction of a given metal is a function of the f a)-density b)-initial temperature c)- temperature difference d)- linear coefficient of thermal expansion e)- final temperature f)- original length
Answers: 2
image
Engineering, 04.07.2019 18:10, jojoangelique13
The flow rate of air through a through a pipe is 0.02 m5/s. a pitot static tube is placed in the flow. the radius of the pitot static tube is 1 mm. assuming the flow to be steady and the air to be at 300k, calculate the difference in total and static pressure if the diameter of the pipe is: (a) d 0.1 m d 0.05 m (c) d 0.01 m
Answers: 2
image
Engineering, 04.07.2019 18:10, krystabrewer3
What are the two (02) benefits, which may result from a successful implementation of preventive maintenance (pm) program in an organization? (clo3)a)- lean manufacturing b)-overlapping responsibilities c)-the planner is not qualified d)-accurate contractor information e)-reduction in equipment redundancies f)-accurate stores information
Answers: 3
Do you know the correct 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:

Konu
Chemistry, 10.10.2020 23:01