473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

help placing rocks in a grid

Can someone help me with what i am missing in this code. I can't get it to compile. Thx!
Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2.  
  3. public class PlaceRocks
  4. {
  5.  
  6. private static final int GRID_SIZE = 3;
  7.     private static final String ROW_PROMPT = "Enter a row from: 0, 1, 2";
  8.     private static final String COLUMN_PROMPT =
  9. "Enter a column from: 0, 1, 2";
  10.     private static final String DENIED = "This row/column is already taken.";
  11.     private static final String ACCEPTED = "Done.";
  12.  
  13.  
  14.     public static void main(String[] s)
  15. {
  16.         boolean[] columns = new boolean[GRID_SIZE];
  17.         boolean[] rows = new boolean[GRID_SIZE];
  18.  
  19.  
  20. for(int j = 0; j < 3; j++)
  21. {
  22. String inputRow = JOptionPane.showInputDialog(ROW_PROMPT);
  23.             int rowNumber = Integer.parseInt(inputRow);
  24.  
  25. String inputColumn = JOptionPane.showInputDialog(COLUMN_PROMPT);
  26.             int columnNumber = Integer.parseInt(inputColumn);
  27.  
  28.             if (isCellTaken(rowNumber, columnNumber,
  29.     rows, columns))
  30. {
  31.     JOptionPane.showMessageDialog(null, DENIED);
  32.             }
  33.             else
  34. {
  35.     rows[rowNumber] = true;
  36.     columns[columnNumber] = true;
  37.     JOptionPane.showMessageDialog(null, ACCEPTED);
  38.             }
  39.         }
  40.     }
  41.  
  42.  
  43.     private static boolean isCellTaken(rows, columns, row, column)
  44. {
  45.         if(rows[row] && columns[column])
  46. {
  47.             return true;
  48.         }
  49.         else
  50. {
  51. return false;
  52. }
  53.  
  54. }
  55.  
  56. }
May 30 '07 #1
3 1134
JosAH
11,448 Expert 8TB
Can someone help me with what i am missing in this code. I can't get it to compile. Thx!
The compiler must've spewed out a bit more than "I can't compile this". Copy
and paste the compiler diagnostic message(s) here and we'll see if we can help.

kind regards,

Jos
May 30 '07 #2
D:\Documents and Settings\amy.asher\My Documents\ICS 141\PlaceRocks.java:43: <identifier> expected
private static boolean isCellTaken(rows, columns, row, column)
^
D:\Documents and Settings\amy.asher\My Documents\ICS 141\PlaceRocks.java:54: ')' expected
}
^
D:\Documents and Settings\amy.asher\My Documents\ICS 141\PlaceRocks.java:43: cannot resolve symbol
symbol : class rows
location: class PlaceRocks
private static boolean isCellTaken(rows, columns, row, column)
^
D:\Documents and Settings\amy.asher\My Documents\ICS 141\PlaceRocks.java:28: isCellTaken(rows) in PlaceRocks cannot be applied to (int,int,boolean[],boolean[])
if (isCellTaken(rowNumber, columnNumber,
^
D:\Documents and Settings\amy.asher\My Documents\ICS 141\PlaceRocks.java:43: missing method body, or declare abstract
private static boolean isCellTaken(rows, columns, row, column)
^
5 errors

Tool completed with exit code 1
May 30 '07 #3
JosAH
11,448 Expert 8TB
Your curly brackets and/or parentheses aren't balanced; check them all.

kind regards,

Jos
May 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Roy Riddex | last post by:
I have a text file which holds data for 30 cars in the following way: CarRegistration CarType CarClass Available I'm trying to display the full contents of this...
2
by: amita | last post by:
when i am writing a program in c# using windows app I am getting this error message as System.Windows.Forms.Control.Text is inaccessable due to its protection level. In the design window when i...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
4
by: pradeepbadiger | last post by:
Hi, I created a visual component class in C# which is derived from System.Windows.Forms.UserControl. Now i want to place it on the grid....I m not able to assign the control to the grid cell....
0
by: derik | last post by:
04:57:10 172.16.30.239 GET /name/Admin.aspx 200 04:57:10 172.16.30.239 GET /name/Admin_topbanner.aspx 200 can any one help me in delimiting this these text should be placed in a data grid...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
1
by: saytri | last post by:
I have a problem with this code. I'm, doing a quiz, and the questions are stored in a binary file. My problem is how am i going to compare the answers entered by the user to the correct answers. The...
4
by: Energizer100 | last post by:
public class fly extends Actor { public fly() { setColor(Color.BLACK); } public fly(Color flyColor) { setColor(flyColor);
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.