File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot resolve symbol

 
S. Stacey
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks sj that worked perfectly....
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic