游戏和GameHelper分为两类,编译器显示两个错误
game.java:7:错误:找不到符号
GameHelper helper = new GameHelper();
^
符号:类GameHelper
地点:上课游戏
game.java:7:错误:找不到符号
GameHelper helper = new GameHelper();
^
符号:类GameHelper
地点:上课游戏
2个错误
游戏类
class game
{
public static void main(String[]args)
{
String g;
sinkdot one=new sinkdot();
GameHelper helper=new GameHelper();
int randnum=(int)(Math.random()*7);
int[] locs={randnum,randnum+1,randnum+2};
int guesscount=0;
one.locationsetter(locs);
boolean isAlive=true;
while(isAlive==true)
{
System.out.println("Enter your guess");
g=helper.getUserInput("Enter a number");
guesscount=guesscount+1;
String returnval=one.checkyourself(g);
System.out.println(returnval);
if(returnval.equals("Kill"))
{
isAlive=false;
break;
}
}
System.out.println("Number of attempts are"+guesscount);
}
}
GameHelper类
import java.io.*;
public class GameHelper{
public String getUserInput(String prompt){
String inputLine=null;
System.out.print(prompt+" ");
try{
BufferedReader is=new BufferedReader(new InputStreamReader(System.in));
inputLine=is.readLine();
if(inputLine.length()==0){
return null;
}
catch(IOException e){
System.out.println("IOException:"+e);
}
return inputLine;
}
}
}
我正在用javac game.java编译它。在sinkdot类中没有错误所以我没有提到它。