I have to write a quiz tool in java and i am stuck. I just want to create a question and fill it with answers. The answeres should be in the array "antworten".
MainQuiz.java class:
import java.lang.*;
public class MainQuiz {
public static void main(String args[]){
QuizFrage qf = new QuizFrage ("Welche Lebensmittel sind gesund?" ,
new QuizAntwort ("Apfel" ,"A" , true),
new QuizAntwort ("Chips", "B", false),
new QuizAntwort ("Orange" , "C", true),
new QuizAntwort ("Schokolade" , "D", false));
qf.FrageStellen();
}
}
QuizAntwort.java class:
public class QuizAntwort {
protected String antwortxt;
protected Boolean istrichtig;
protected CharSequence antwortchr;
public QuizAntwort(String string, String string2, boolean b) {
// TODO Auto-generated constructor stub
}
public boolean checkAntwort(String gewaehlteAntworten) {
if (gewaehlteAntworten.contains(antwortchr)) return true; else return false;
}
}
and QuizFrage.java class
public class QuizFrage {
private String fragentext;
private QuizAntwort antworten[];
public QuizFrage(String FrageString, QuizAntwort quizAntwort1,
QuizAntwort quizAntwort2, QuizAntwort quizAntwort3,
QuizAntwort quizAntwort4){
fragentext = FrageString;
}
public void FrageStellen(){
System.out.println(fragentext);
for (QuizAntwort curantwort: antworten){
System.out.println(curantwort.antwortchr + ": " + curantwort.antwortxt);
}
}
}
How do I fill the array "antworten" with quizantwort1,quizantwort2... ?