Page 1 of 1

Create 2 classes that implement Question: (1) MultipleChoiceQuestion, (2)FillInTheBlankQuestion. Create 2 classes that i

Posted: Sat Nov 27, 2021 2:25 pm
by answerhappygod
Create 2 classes that
implement Question:
(1) MultipleChoiceQuestion, (2)FillInTheBlankQuestion.
Create 2 classes that
implement Answer, each one corresponds to one
Question type above:
(1) MultipleChoiceAnswer, (2) SingleWordAnswer.
How would I implement Question and Answer to create the classes
needed?
Given:
Create 2 Classes That Implement Question 1 Multiplechoicequestion 2 Fillintheblankquestion Create 2 Classes That I 1
Create 2 Classes That Implement Question 1 Multiplechoicequestion 2 Fillintheblankquestion Create 2 Classes That I 1 (133.49 KiB) Viewed 66 times
Create 2 Classes That Implement Question 1 Multiplechoicequestion 2 Fillintheblankquestion Create 2 Classes That I 2
Create 2 Classes That Implement Question 1 Multiplechoicequestion 2 Fillintheblankquestion Create 2 Classes That I 2 (44.64 KiB) Viewed 66 times
public interface Question * Returns the text of the question for display to the user */ public String getTextPrompt(); /** * Returns an array of all the possible answers a user may resond * to this question with. If this question does not provide a list * of possible answers, this method throws an exception */ public Answer [] getPossibleAnswers() throws NoAnswersException; * Returns the true answer to this question. If this question * does not have a single true answer, this method throws an * exception */ public Answer getCorrectAnswer() throws NoCorrectAnswerException; /** * Given a string entered by the user, this method returns * an appropriate answer object that represents the user's * response. If no such answer object can be created due to * the user's response being invalid, this method throws an * exception */ public Answer convertResponseToAnswer(String userResponse) throws InvalidResponseException; }

public interface Answer { /** * Returns a String that represents this Answer, * formatted for the user */ public String toString(); /** * Returns true if the other may be considered the same answer * as this one. */ public boolean isSameAs (Answer other); }