Can someone help me with what i am missing in this code. I can't get it to compile. Thx!
[code=java]
import javax.swing.*;
public class PlaceRocks
{
private static final int GRID_SIZE = 3;
private static final String ROW_PROMPT = "Enter a row from: 0, 1, 2";
private static final String COLUMN_PROMPT =
"Enter a column from: 0, 1, 2";
private static final String DENIED = "This row/column is already taken.";
private static final String ACCEPTED = "Done.";
public static void main(String[] s)
{
boolean[] columns = new boolean[GRID_SIZE];
boolean[] rows = new boolean[GRID_SIZE];
for(int j = 0; j < 3; j++)
{
String inputRow = JOptionPane.sho wInputDialog(RO W_PROMPT);
int rowNumber = Integer.parseIn t(inputRow);
String inputColumn = JOptionPane.sho wInputDialog(CO LUMN_PROMPT);
int columnNumber = Integer.parseIn t(inputColumn);
if (isCellTaken(ro wNumber, columnNumber,
rows, columns))
{
JOptionPane.sho wMessageDialog( null, DENIED);
}
else
{
rows[rowNumber] = true;
columns[columnNumber] = true;
JOptionPane.sho wMessageDialog( null, ACCEPTED);
}
}
}
private static boolean isCellTaken(row s, columns, row, column)
{
if(rows[row] && columns[column])
{
return true;
}
else
{
return false;
}
}
}[/code]
[code=java]
import javax.swing.*;
public class PlaceRocks
{
private static final int GRID_SIZE = 3;
private static final String ROW_PROMPT = "Enter a row from: 0, 1, 2";
private static final String COLUMN_PROMPT =
"Enter a column from: 0, 1, 2";
private static final String DENIED = "This row/column is already taken.";
private static final String ACCEPTED = "Done.";
public static void main(String[] s)
{
boolean[] columns = new boolean[GRID_SIZE];
boolean[] rows = new boolean[GRID_SIZE];
for(int j = 0; j < 3; j++)
{
String inputRow = JOptionPane.sho wInputDialog(RO W_PROMPT);
int rowNumber = Integer.parseIn t(inputRow);
String inputColumn = JOptionPane.sho wInputDialog(CO LUMN_PROMPT);
int columnNumber = Integer.parseIn t(inputColumn);
if (isCellTaken(ro wNumber, columnNumber,
rows, columns))
{
JOptionPane.sho wMessageDialog( null, DENIED);
}
else
{
rows[rowNumber] = true;
columns[columnNumber] = true;
JOptionPane.sho wMessageDialog( null, ACCEPTED);
}
}
}
private static boolean isCellTaken(row s, columns, row, column)
{
if(rows[row] && columns[column])
{
return true;
}
else
{
return false;
}
}
}[/code]
Comment