ecco il codice,ha i ragione.
codice:
import java.util.Scanner;
public class TestRisposta {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Domande dom = new Domande();
String stringa = "";
// String uno = dom.getPRIMA_DOMANDA();
System.out.println(dom.getPRIMA_DOMANDA());
System.out.println("4\t" + "5\t\n" + "3\t" + "6\t");
System.out.println("Digita la risposta esatta e premi enter, oppure scrivi \"fine\" per terminare il programma.");
while (!(stringa = scanner.nextLine()).equals("fine")) {
try {
verificaRisposta(stringa);
//scanner.close(); ho provato a mettere questo ma mi restituisce una eccezione
}
catch (Exception ex) {
ex.printStackTrace();
}
}
System.out.println("Fine programma!");
}
public static void verificaRisposta(String stringa) throws Exception {
if (stringa.equals(RisposteDomandaA.RISPOSTA_UNO.getRisposta())) {
System.out.println("Risposta errata!!!");
} else if (stringa.equals(RisposteDomandaA.RISPOSTA_DUE.getRisposta())) {
System.out.println("Risposta errata!!!");
} else if (stringa.equals(RisposteDomandaA.RISPOSTA_TRE.getRisposta())) {
System.out.println("BRAVO!!! Hai indovinato!");
} else if (stringa.equals(RisposteDomandaA.RISPOSTA_QUATTRO.getRisposta())) {
System.out.println("Risposta errata!!!");
} else if (!(stringa.equals(RisposteDomandaA.RISPOSTA_CINQUE.getRisposta()))) {
System.out.println("Fine del programma...");
}
}
}