1  /**
  2     A question with a text and an answer.
  3  */
  4  public class Question
  5  {
  6     private String text;
  7     private String answer;
  8  
  9     /**
 10        Constructs a question with a given text and an empty answer.
 11        @param questionText the text of this question
 12     */
 13     public Question(String questionText) 
 14     {
 15        text = questionText;
 16        answer = "";
 17     }
 18  
 19     /**
 20        Sets the answer for this question.
 21        @param correctResponse the answer
 22     */
 23     public void setAnswer(String correctResponse)
 24     {
 25        answer = correctResponse;
 26     }
 27  
 28     /**
 29        Checks a given response for correctness.
 30        @param response the response to check
 31        @return true if the response was correct, false otherwise
 32     */
 33     public boolean checkAnswer(String response)
 34     {
 35        return response.equals(answer);
 36     }
 37  
 38     /**
 39        Displays this question.
 40     */
 41     public void display()
 42     {
 43        System.out.println(text);
 44     }
 45  }