package exercise2.choice; import java.util.*; import exercise2.*; public class ChoiceExerciseModel extends ExerciseModel { public static final int CHOOSE_ONE = 0; public static final int CHOOSE_ANY = 1; protected int type; protected String[] choices; public ChoiceExerciseModel() { } public void setSpecialProperties(Map properties) { String value; // Set the type. value = (String)properties.get("type"); type = Integer.parseInt(value); // Set the choices. value = (String)properties.get("numChoices"); int numChoices = Integer.parseInt(value); choices = new String[numChoices]; for (int i = 0; i < numChoices; i++) { choices[i] = (String)properties.get("choice_" + i); } } public int getType() { return type; } public int getNumChoices() { return choices.length; } public String[] getChoices() { return choices; } }