Boa noite a todos!
Eu estou lendo o livro "Use a cabeça! Java" e eu copiei um código do livro que não esta rodando, eu não sei o motivo, pois até onde consigo ver copiei o código igual ao que esta no livro.
public class SimpleDotComGame {
public static void main (String[] args){
GameHelper helper = new GameHelper();
SimpleDotCom theDotCom = new SimpleDotCom();
int randomNum = (int) (Math.random() * 5);
int[] locations = (randomNum, randomNum + 1, randomNum + 2);
theDotCom.setLocationCells(locations);
boolean isAlive = true;
while(isAlive == true){
Sring guess = helper.getUserInput("Insira um numero: ");
String result = theDotCom.checkYourself(guess);
numOfGuesses++;
if(result.equals("Kill")){
isAlive = false;
System.out.println("Voce usou " + numOfGuesses + "palpites.");
}
}
}
}
SimpleDotComGame.java:9: ')' expected
int[] locations = (randomNum, randomNum + 1, randomNum + 2);
^
SimpleDotComGame.java:9: ';' expected
int[] locations = (randomNum, randomNum + 1, randomNum + 2);
^
SimpleDotComGame.java:9: not a statement
int[] locations = (randomNum, randomNum + 1, randomNum + 2);
^
SimpleDotComGame.java:9: ';' expected
int[] locations = (randomNum, randomNum + 1, randomNum + 2);
^
4 errors
Se alguém, puder me dar uma ajuda a entender esse erro eu agradeço.