This site requires JavaScript, please enable it in your browser!
Greenfoot back
adlafforest
adlafforest wrote ...

2017/3/10

Geography quiz

adlafforest adlafforest

2017/3/10

#
How do I associate/connect a certain picture to each quiz question? I would like to have the map of a specific country show up for each question, and have the player select the correct name, among the four possible answers, for said country. String questionText = "What country is this?"; ArrayList<Answer> answers = new ArrayList<Answer>(); answers.add(new Answer("Lithuania", false)); answers.add(new Answer("Latvia", false)); answers.add(new Answer("Estonia", true)); answers.add(new Answer("Belarus", false));
danpost danpost

2017/3/10

#
You can make the String objects be the common factor. Save the strings instead of the Answer objects. Have the filename of the pictures also be the same string with all pictures having the same extension. This way, you can even vary the answer to the same question -- one of the strings can be randomly picked to be the right answer. Its image is shown, the Answer objects are created with the chosen one getting the 'true' parameter.
You need to login to post a reply.