Genesis2kx
March 25, 2008, 04:01 PM
I have this code to complete but the instructions state the main method should be left as is which is as follows:
import javax.swing.JOptionPane;
public class GuessingGame {
public static void main(String[] args){
int guess; // the user’s guess
int target = getnum(); //a random number selected by the computer
do{
guess = getguess(); //gets a guess from the user
checkguess(guess,target); // compares the guess to the target
}while (guess != target); /* keep doing this as long as the user has not
* guessed the target number
*/
}
I get errors on the int target = getnum(); and guess = getguess(); lines.
GuessingGame.java:12: getnum(int) in GuessingGame cannot be applied to ()
int target = getnum(); //a random number selected by the computer
GuessingGame.java:15: getguess(int) in GuessingGame cannot be applied to ()
guess = getguess(); //gets a guess from the user
I have more code below without error so is it safe to assume the instructions are wrong about not changing the main method? It seems the blank parameters ( ) called by the parameters I wrote is the problem in the main method.
import javax.swing.JOptionPane;
public class GuessingGame {
public static void main(String[] args){
int guess; // the user’s guess
int target = getnum(); //a random number selected by the computer
do{
guess = getguess(); //gets a guess from the user
checkguess(guess,target); // compares the guess to the target
}while (guess != target); /* keep doing this as long as the user has not
* guessed the target number
*/
}
I get errors on the int target = getnum(); and guess = getguess(); lines.
GuessingGame.java:12: getnum(int) in GuessingGame cannot be applied to ()
int target = getnum(); //a random number selected by the computer
GuessingGame.java:15: getguess(int) in GuessingGame cannot be applied to ()
guess = getguess(); //gets a guess from the user
I have more code below without error so is it safe to assume the instructions are wrong about not changing the main method? It seems the blank parameters ( ) called by the parameters I wrote is the problem in the main method.