im here this time to ask you how to make a controller for this little program.
Basicaly i shuffle the array list and use a sysout, than i ask to put it in order and i use a do-while with an if to catch the answer.
what i would like to do now is to catch if any of two wrong answers are present.
Like, if the number 5 or 6 is present it tells there is an error. But i do not udnerstand how to do it.
here the code:
public class Test {
public static void main(String[] args) {
java.util.Random randomGenerator = new java.util.Random();
Scanner scan = new Scanner(System.in);
List<String> coffeeList = Arrays.asList("1 pick it","2 drink it","3 cook","4 put it in a cup","5 salt it","6 dream it");
Collections.shuffle(coffeeList);
for(String value : coffeeList)
System.out.println(value);
System.out.println("\n" + "ora metti in ordine la lista indicando i numeri");
int rispostaGiusta = 0;
boolean flag = false;
rispostaGiusta = scan.nextInt();
do {
if(rispostaGiusta == 1342) {
System.out.println("\n" + "la risposta è giusta");
flag = true;
}
else {
System.out.println("\n" + "la rispsota non è giusta ritenta");
rispostaGiusta = scan.nextInt();
}
} while(!flag);
}
}