I'm new to doing Java and i was wondering if anyone would happen to know why this return type error is occurring.
this is the following error
C:\Users\..\Desktop\Connect4Model.invalid method declaration; return type required
public reset(int numCols, int numRows)
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;
// public Connect4Model(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);
// }
//}
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;
}
public 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);
}
}
void reset()
{
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 >= 1 && selectedOption <= 3) // valid
{
autoplay = selectedOption;
return true;
}
else
return false;
}
int getSuggestedMove(int player_colour)
{
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();
}
}