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 empty question and answer.
 11     */
 12     public Question() 
 13     {
 14        text = "";
 15        answer = "";
 16     }
 17  
 18     /**
 19        Sets the question text.
 20        @param questionText the text of this question
 21     */
 22     public void setText(String questionText)   
 23     {
 24        text = questionText;
 25     }
 26  
 27     /**
 28        Sets the answer for this question.
 29        @param correctResponse the answer
 30     */
 31     public void setAnswer(String correctResponse)
 32     {
 33        answer = correctResponse;
 34     }
 35  
 36     /**
 37        Checks a given response for correctness.
 38        @param response the response to check
 39        @return true if the response was correct, false otherwise
 40     */
 41     public boolean checkAnswer(String response)
 42     {
 43        return response.equals(answer);
 44     }
 45  
 46     /**
 47        Displays this question.
 48     */
 49     public void display()
 50     {
 51        System.out.println(text);
 52     }
 53  }