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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started