Question: Please add comments and javadoc, make sure is code is written correctly, bracket, semi colans etc. Thanks public class Cell { // Displays 'B' for

Please add comments and javadoc, make sure is code is written correctly, bracket, semi colans etc. Thanks

public class Cell

{

// Displays 'B' for the black disk player.

public static final char BLACK = 'B';

// Displays 'W' for the white disk player.

public static final char WHITE = 'W';

// Displays '*' for the possible moves available.

public static final char CANSELECT = '*';

// If the cell is empty or not.

public boolean empty;

// If the cell can be selected or not.

public boolean canselect;

// empty = -1 , white = 0 , black = 1

public int value;

public Cell()

{

this.empty = true;

this.value = -1;

}

public boolean isEmpty()

{

return this.empty;

}

public int getPlayer()

{

return this.value;

}

public void placeChip(int player)

{

this.empty = false;

this.value = player;

}

public void changeChip()

{

placeChip((value + 1) % 2);

}

public void setSelect()

{

this.canselect = true;

}

public boolean canSelect()

{

return this.canselect;

}

public void unselect()

{

this.canselect = false;

}

public void display()

{

// If cell empty.

if (this.isEmpty())

{

// If cell can be selected.

if (this.canselect)

System.out.print("[ " + CANSELECT + " ]"); // Print "*."

// Print empty space.

else

System.out.print("[ " + " " + " ]");

}

else

{

char content = BLACK;

if (this.value == 0)

content = WHITE;

System.out.print("[ " + content + " ]"); // For black "B" & for white "W."

}

}

}

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!