Question: How do I do the following in Java? I have a Box Class that I need to initialise the variables as per the below code,

How do I do the following in Java?

I have a Box Class that I need to initialise the variables as per the below code, the row is 3 and the column is 3. The Player Class is Enum and the code is attached below the Box Class

public class Box {

Player content; // The move this box holds (Empty, X, or O)

int row, col; // Row and column of this box (Not currently used but possibly useful in future updates)

/**

* Constructor

*/

public Box(int row, int col) {

// TODO: Initialise the variables row, col, and content

}

/**

* Clear the box content to EMPTY

*/

public void clear() {

// TODO: Set the value of content to EMPTY (Remember this is an enum)

}

/**

* Display the content of the box

*/

public void display() {

// TODO: Print the content of this box (" X " if it Player.X, " O " for Player.O and " " for Player.Empty)

// Hint: Can use an if-else or switch statement

***************************************************************************************************

** * Enumeration for the players move */

public enum Player { EMPTY, X, O }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!