Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objective: Write the backend classes for the game PickTheOneGame. There are 20 s

ID: 3677949 • Letter: O

Question

Objective:

Write the backend classes for the game PickTheOneGame. 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.

Specification:

Create a class Spacewith the following instance variables:

selected - a boolean varaible that represents whether the space has been selected or not

isTheOne - a boolean variable for the one space that's the one!

With the following constructors:

Default constructor - Sets selected and isTheOne initially to false.

Getters & setters for all instance variables

Create a class PickTheOneGameBackendWith instance variables:

spaces - An array of the newly created type Space which corresponds to the spaces of the front end

currTurns - corresponds to the number of turns the player has taken

gameOver - A boolean value that indicates whether or not the game is over

win - A boolean variable that indicates if the player has won.

Constant class variables (in other words, these should be defined with public static final preceding them):

SPACE_AMT - corresponds to the number of spaces in the game, which is 20.

MAX_TURNS - corresponds to the number of turns the player gets to try to find the one, which is 5

Constructors

Default Constructor - sets all of the instance variabels to default values, and initializes the array of spaces.
HINT: you may also want to call resetSpaces here

Getters for all instance variables

Additional methods:

resetSpaces - a method that returns nothing and has no parameters. Used to reset the game. First, all the spaces in the array need to be constructed. Then, a random space is selected to be the one. Finally, the other instance variables currTurns, gameOver, and win need to be set to initial values.

selectSpace - a method that takes an integer corresponding to the index of the space that's selected, and returns nothing. If the selected space has already been selected, do nothing. Otherwise:

set that space's selected value to true, and check if the space is the one. If so, then the game is over and the player has won.

Increment the number of turns, and check to see if the maximum number of turns has been exceeded. If it has, the game is over.

Objective: Write the backend classes for the game PickTheOneGame. 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. Specification: Create a class Space with the following instance variables: selected - a boolean varaible that represents whether the space has been selected or not isTheOne - a boolean variable for the one space that's the one! With the following constructors: Default constructor - Sets selected and isTheOne initially to false. Getters & setters for all instance variables Create a class PickTheOneGameBackend With instance variables: spaces - An array of the newly created type Space which corresponds to the spaces of the front end currTurns - corresponds to the number of turns the player has taken gameOver - A boolean value that indicates whether or not the game is over win - A boolean variable that indicates if the player has won. Constant class variables (in other words, these should be defined with public static final preceding them): SPACE_AMT - corresponds to the number of spaces in the game, which is 20. MAX_TURNS - corresponds to the number of turns the player gets to try to find the one, which is 5 Constructors Default Constructor - sets all of the instance variabels to default values, and initializes the array of spaces. HINT: you may also want to call resetSpaces here Getters for all instance variables Additional methods: resetSpaces - a method that returns nothing and has no parameters. Used to reset the game. First, all the spaces in the array need to be constructed. Then, a random space is selected to be the one. Finally, the other instance variables currTurns, gameOver, and win need to be set to initial values. selectSpace - a method that takes an integer corresponding to the index of the space that's selected, and returns nothing. If the selected space has already been selected, do nothing. Otherwise: set that space's selected value to true, and check if the space is the one. If so, then the game is over and the player has won. Increment the number of turns, and check to see if the maximum number of turns has been exceeded. If it has, the game is over.

Explanation / Answer

}