Write the back end classes that for the game Pick the One. There are 20 spaces a
ID: 643196 • Letter: W
Question
Write the back end classes that for the game Pick the One. There are 20 spaces and you only have 5 chances to pick the right one! Download the Lab15Driver and create the following classes with these specifications. By the way this involves graphics!
Create a class called SpaceInstance Variables
selected a Boolean variable that corresponds if the space has or has not been selected
isTheOne a Boolean variable for the one space thats the one!
Constructors
Default Constructor - Sets selected and isTheOne initially to false
Accessors for all instance variables
Mutators for all instance variables
Create a class called PickTheOneGameBackEndInstance Variables
spaces An array of the newly created type Space which corresponds to the spaces of the front end
currTurns which corresponds to the number of the player has taken
gameOver a Boolean value that indicates whether or not the game is over
win a Boolean value that indicates if the player won
Constant Class Variables (In other words public static final should precede it)
SPACE_AMT corresponds to the number of spaces in the game which is 20
MAX_TURNS corresponds to the number turns the players gets to try to find the one, which is 5
Constructors
Default Constructor Sets all of the instance variables to default values, and initializes the array of spaces. HINT: You may also want to call resetSpaceshere.
Accessors for all instance variables
Other methods
resetSpaces A method that returns nothing and has no parameters that essentially resets the game. First all the spaces in the array of spaces need to be constructed. Then a random space is selected to be the one and its instance variable isTheOne is set to true. Finally the other instance variables, currTurns, gameOver, win needs to be set to initial values (IE currTurns is 0, gameOver is false, and win is false).
selectSpace A method which has one integer parameter index which corresponds to the space thats selected and also the method returns nothing. If the selected space has been selected do nothing. Otherwise set that spaces selected value to true, and then check if that space isTheOne. If that space isTheOne then set gameOver to true and win to true. Then increase currTurns by one. Then check if currTurns has gone over or equal to MAX_TUNRS. If it has then set game over to true.
Also if youre curious your code is being called in the buttonCheck and resetAllButtons method inside of the driver.
Example Dialog:
Write the back end classes that for the game Pick the One. There are 20 spaces and you only have 5 chances to pick the right one! Download the Lab15Driver and create the following classes with these specifications. By the way this involves graphics! Create a class called SpaceInstance Variables selected a Boolean variable that corresponds if the space has or has not been selected isTheOne a Boolean variable for the one space that's the one! Constructors Default Constructor - Sets selected and isTheOne initially to false Accessors for all instance variables Mutators for all instance variables Create a class called PickTheOneGameBackEndInstance Variables spaces An array of the newly created type Space which corresponds to the spaces of the front end currTurns which corresponds to the number of the player has taken gameOver a Boolean value that indicates whether or not the game is over Win a Boolean value that indicates if the player won Constant Class Variables (In other words public static final should precede it) SPACE_AMT corresponds to the number of spaces in the game which is 20 MAX_TURNS corresponds to the number turns the players gets to try to find the one, which is 5 Constructors Default Constructor ½ Sets all of the instance variables to default values, and initializes the array of spaces. HINT: You may also want to call resetSpaceshere. Accessors for all instance variables Other methods resetSpaces A method that returns nothing and has no parameters that essentially resets the game. First all the spaces in the array of spaces need to be constructed. Then a random space is selected to be the one and its instance variable isTheOne is set to true. Finally the other instance variables, currTurns, gameOver, win needs to be set to initial values (IE currTurns is 0, gameOver is false, and win is false). selectSpace A method which has one integer parameter index which corresponds to the space that's selected and also the method returns nothing. If the selected space has been selected do nothing. Otherwise set that spaces selected value to true, and then check if that space isTheOne. If that space isTheOne then set gameOver to true and win to true. Then increase currTurns by one. Then check if currTurns has gone over or equal to MAX_TUNRS. If it has then set game over to true. Also if you're curious your code is being called in the buttonCheck and resetAllButtons method inside of the driver. Example Dialog:Explanation / Answer
class SpaceInstance
{
Boolean selected, isTheOne;
SpaceInstance()
{
selected=false;
isTheOne=false;
}
}
class PickTheOneGameBackEndInstance {
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.