Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago