public class SimpleDotCom {
public static void main(String[] args) {
int[] locationCells;
int numOfHits = 0;
public String checkYourself (String stringGuess) {
int guess = Integer.parseInt(stringGuess);
String result = "miss";
for(int cell : locationCells) {
if(guess == cell) {
result = "hit";
numOfHits ++;
break;
}
}
if(numOfHits == locationCells.length) {
result = "kill";
}
System.out.println(result);
}
public void setLocationCells (int[] locs) {
locationCells = locs;
}
}
}
错误提示:第7行 Multiple markers at this line
- Syntax error on token "(", ; expected
- Illegal modifier for parameter checkYourself; only final is
permitted
第22行 Multiple markers at this line
- Syntax error on token ")", ; expected
- void is an invalid type for the variable
setLocationCells