I am building a Connect Four game, and here's my checker:
static final int ROWS = 6;
public void checkIfFull(int colu)
{
/*deleted*/
}
This is invoked when the user clicks on a button:
if (e.getSource () == b1)
{
checkIfFull (0);
}
This is my method in positioning the token at the lowest open level:
public void setPos(int column)
{
if (demise) return; //this is for when the game is already over and the user
still attempts to click on a button
int row;
for (row = 0; row < ROWS; ++row)
{
if (slots[row][column] > 0)
break;
}
if (row > 0)
{
//save current player
slots[--row][column] = active;
//change turns
/*if (active == GREEN)
{
active = RED;
activeMe ();
}
else if (active == RED)
{
active = GREEN;
activeMe();
} I moved this to setCircle method*/
setCircle(active, row, column); //gui method used to fill up the empty circle
}
}
As of the moment when I fill up a column, the Joptionpane doesn't pop up, but it's supposed to.
Any clues?
I'm still continuously studying the logic I have, so if there are other flaws you can see, please do point them out. :)