• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot resolve symbol

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks sj that worked perfectly....
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic