Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error: cannot resolve symbol

 
Joseph Carr
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fairly new to the java platform. I have just installed it and done everything that i know to do. As far as i know everything is right. I was putting in a program from the new HEAD FIRST java book, which is exceptionally well written might i add, however when i put in the code my computer isnt recognizing the dot operator and some other interesting parts of what i would call a pretty simple program. Please help, i want to make sure i am doing everything right. To give you a good idea what is going on: I have installed j2sdk1.4.2_03 and changed my path name and i have even written a simple hello world program. So i knnow that everything is working ok. I am thinking i am missing a plug in or have a file in the wrong direstory, but i still don't really know. Please help!!

everywhere <<<< is where the error is given to me.
public class GuessGame {
Player p1;
Player p2;
Player p3;
public void startgame() {
p1 = new Player();
p2 = new Player();
p3 = new Player();
int guess1 = 0;
int guess2 = 0;
int guess3 = 0;
boolean p1isRight = false;
boolean p2isRight = false;
boolean p3isRight = false;
int targetNumber = (int) (Math.random() * 10);
System.out.println("I'm thinking of a number between 0 and 9...");
while(true) {
System.out.println("Number to guess is " + targetNumber);
p1.guess();
p2.guess();
p3.guess();
guessp1 = p1.number;
System.out.println("Player one guessed " + guessp1); <<<<<
guessp2 = p2.number;
System.out.println("Player two guessed " + guessp2); <<<<<
guessp3 = p3.number;
System.out.println("Player three guessed " + guessp3); <<<<<

if (guessp1 == targetNumber) { <<<<<
p1isRight = true;
}
if (guessp2 == targetNumber) { <<<<<
p2isRight = true;
}
if (guessp3 == targetNumber) { <<<<<
p3isRight = true;
}
if (p1isRight || p2isRight || p3isRight) {
System.out.println("We have a winner!");
System.out.println("Player one got it right?" + p1isRight);
System.out.println("Player two got it right?" + p2isRight);
System.out.println("Player three got it right?" + p3isRight);
System.out.println("Game is over");
break;
} else {

System.out.println("Players will have to try again.");
}
}
}
}


there are others but ive forgotten how to look page by page in dos...oopsie.
[ December 11, 2003: Message edited by: Joseph Carr ]
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Unless I'm mistaken, you want your variable guessp1 to be guess1 as you defined earlier in the file, no? Same with the other two files.
 
Joseph Carr
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. everything is good with that class. But i still have problems with the dot operator, in a another portion of the program, in this class below:
public class GameLauncher {
public static void main (String[] args) {
GuessGame game = new GuessGame();
game.startGame(); <<<<< here it doesnt like the dot
}
}

is there more i can do???
 
Manoj Zachariah
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should be
game.startgame();
as your function is written fully in lowercase..
 
Joseph Carr
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is their a prize for the dumbest question?

though i will have to say i copied it directly from the Head First book...
and i checked it has a capital "G"...
[ December 12, 2003: Message edited by: Joseph Carr ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic