Im trying to call the reset method within this Connect4Model class is that possible. As you can see I have made and attempt and I'm getting 33 errors. I can't exactly see where I'm going wrong. If someone can guide me and let me know where I've gone wrong that would be grateful.
public class Connect4Model
{
Connect4Column [] columns; // an array of columns
int NUM_COLUMNS; // how many columns we have in the game
int NUM_ROWS; // how many rows we have in the game
int playerToGoNext = Connect4Column.RED_COUNTER; //can be red or yellow
int autoplay;
int suggestedmove;
public Connect4Model
{
Connect4Model.reset();
}
int getNumCols() // simply return the number of columns
{
return NUM_COLUMNS;
}
int getNumRows() // simply return the number of rows
{
return NUM_ROWS;
}
int getNextPlayer() // returns who gets to go next
{
return playerToGoNext;
}
void reset(int numCols, int numRows)
{
NUM_COLUMNS = numCols;
NUM_ROWS = numRows;
columns = new Connect4Column[NUM_COLUMNS];
for (int i=0; i < NUM_COLUMNS; i++) {
columns[i] = new Connect4Column(NUM_ROWS);
}
for (int thisCol = 0; thisCol < NUM_COLUMNS; thisCol ++)
{
for (int thisRow = 0; thisRow < NUM_ROWS; thisRow ++)
{
columns[thisCol].numCounters = 0;
columns[thisCol].counters[thisRow] = 0;
}
}
}
int getAutoplay()
{
return autoplay;
}
boolean setAutoplay(int selectedOption)
{
if(selectedOption >= 0 && selectedOption <= 2) // valid
{
autoplay = selectedOption;
return true;
}
else
return false;
}
int getSuggestedMove(int player_colour) // 2.5
{
java.util.Random r = new java.util.Random();
return r.nextInt(NUM_COLUMNS);
}
boolean go(int thisColumn) // try to put a counter at this col
{
if(thisColumn<0 || thisColumn>=NUM_COLUMNS)
return false;
//System.out.println("thisCol is " + thisColumn);
if(columns[thisColumn].addCounter(playerToGoNext)==true)
{
if(playerToGoNext==Connect4Column.YELLOW_COUNTER)
playerToGoNext=Connect4Column.RED_COUNTER;
else
playerToGoNext=Connect4Column.YELLOW_COUNTER;
return true;
}
return false;
}
int getCounter(int thisColumn, int thisRow) //
{
if(thisColumn<0 || thisColumn>=NUM_COLUMNS)
return 0;
return columns[thisColumn].getCounter(thisRow);
}
int getNumCounters(int thisColumn) //
{
if(thisColumn<0 || thisColumn>=NUM_COLUMNS)
return 0;
return columns[thisColumn].getNumCounters();
}
}