這裏是代碼在那裏我遇到了問題:「找不到符號:變量輸入」錯誤
import java.util.*;
public class Game {
public static final int ROCK = 1;
public static final int PAPER = 2;
public static final int SCISSORS = 3;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name = intro();
int numRounds = numRounds(name);
game(name, numRounds);
}
public static String intro() {
System.out.println("Welcome to Rock Paper Scissors. I, the computer, will be your opponent.");
System.out.print("Please type in your name and press return: ");
String name = input.nextLine();
return name;
}
public static int numRounds(String name) {
System.out.println("Welcome " + name + ".");
System.out.println("All right " + name + ". How many games would you like to play?");
System.out.print("Enter the number of rounds you want to play and press return: ");
int numRounds = input.nextInt();
return numRounds;
}
當我使用掃描儀來獲取用戶名和輪數,他們會值喜歡玩,我得到的錯誤。我只想返回這些值在主函數中使用。
任何幫助,將不勝感激。
「遊戲」方法的實現在哪裏? –