aspose file tools*
The moose likes Beginning Java and the fly likes cannot resolve symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot resolve symbol" Watch "cannot resolve symbol" New topic
Author

cannot resolve symbol

S. Stacey
Greenhorn

Joined: Jul 03, 2003
Posts: 20
Hello All,
When I complie my code I am getting a cannot reslove symbol error in my test class and I have no idea what is wrong. The error is received on the following line: Game userplay = new Game();

I was hoping that someone on here would be able to help me.
Here is my class:

Here is my test class:
Matt Fyffe
Greenhorn

Joined: Jun 19, 2003
Posts: 25
Well, I'm not sure if this would cause it or not, but you don't have a constructor in game that has no arguements but that is what you are calling in that line. If that's not it, I'm out of ideas.
S. Stacey
Greenhorn

Joined: Jul 03, 2003
Posts: 20
Thanks Matt that worked.
I got the program running but it was not running the way it should be so I made some changes to the test class and now I am running into some other troubles.

I am getting a can not resolve symbol that points to the varibale tries: System.out.println ("You threw " + tries + " times and you won " + userplay.getHits());
I think I am getting the error because of the scope of the varibale tries, but I am not sure how to fix it....what do you all think?
Thanks
Stacey
[ July 10, 2003: Message edited by: Stacey ]
Sree Yemparala
Greenhorn

Joined: Jul 10, 2003
Posts: 6
declare and intialize the tries variable outside the if condition like
int tries =0;
and inside the if condition
replace the line
int tries = Integer.parseInt(JOptionPane.showInputDialog( "How many times would you like to play the
with
tries = Integer.parseInt(JOptionPane.showInputDialog( "How many times would you like to play the
This will surely solve the cannot resolve symbol problem.
I hope this helps.
Good Luck
sj
S. Stacey
Greenhorn

Joined: Jul 03, 2003
Posts: 20
thanks sj that worked perfectly....
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Stacey,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to comply with the JavaRanch Naming Policy. You can change it here. Thank you for your cooperation.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot resolve symbol