Hi I need help on a program I am currently working on since I am a noob with java.
It is basically a simple console program that prompts the user to choose 3 options: Exit, Load First Playlist and Load Second Playlist. I need to add certain functions such as when the user types a letter instead of a number, a message will appear prompting the user to type in a number instead of a letter. And if the user typed in a different number instead of 1,2,3 a message will appear prompting the user to choose one of those numbers.
private ExampleOption getOptionFromUser() {
Scanner in = new Scanner(System.in);
while (true) {
int num = in.nextInt();
for (ExampleOption option : options) {
if (option.getOptionNumber() == num) {
return option;
}
}
}
}
Thanks
Aucun commentaire:
Enregistrer un commentaire