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."); } } } } public class player { int number = 0;
public void guess() { number = (int) (Math.random() * 10); System.out.println("I'm guessing" + number); } } public class GameLauncher { public static void main (String [] args) { GuessGame game = new GuessGame(); game.startGame(); } }
"The Choices We Make, Dictates Our Life To Lead".
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35224
7
posted
0
If it doesn't compile, there must have been an error message, right? What was it? (What the file name will be you'll see as soon as it does compile :-)
In the future, if you post code of any length, surround it with CODE tags, which you can do by clicking the "CODE" button underneath the text entry area. That way, the code will be displayed formatted.
Change the following in your code and your class name is
compile and run
bye for now sat
Sumi Festus
Greenhorn
Joined: Feb 04, 2005
Posts: 14
posted
0
Hi!!
There can be only one public class so just make the class GameLaucher as public and remove the public keyword from the other 2 classes. Also remember that naming convention is to capitalise the class names. It is a good and the right way of coding.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
... Another thing that you should get used to is putting each (top-level) class in its own file. Making all but one of your classes non-public is a hack. In the long run, whether or not a class is public is a design decision but the reason should not be because one was too lazy to create separate files.
There is no emoticon for what I am feeling!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: The Code is not compiling,and also tell me what will be the filename for this code