Sorry for the newbie question in advance. Is there a better way to describe my if statement?
public static void Replay(){
String[] yes = {"yes", "Yes", "y", "Y"};
System.out.println("Would you like to replay?"); //asks user to replay
Scanner in = new Scanner(System.in); //creates scanner
String replay = in.nextLine(); //stores answer in variable 'replay'
if (replay.equals(yes[0]) || replay.equals(yes[1]) || replay.equals(yes[2]) || replay.equals(yes[3])) {
createInput(); // if yes then call method again
} else {
System.out.println("Thanks for playing.");
}
}
Aucun commentaire:
Enregistrer un commentaire