Question
How I can override a question in this class The FillInQuestion subclass Create a class called FillInQuestion that extends Question. This kind of question is
How I can override a question in this class
The FillInQuestion subclass
Create a class called FillInQuestion that extends Question. This kind of question is created using a single string that contains the answer, surrounded by _- -_. A sample question like this would be The color _-white-_ is the most common color found on flags. The question should be displayed to the user as The color _____ is the most common color found on flags.
The first line of the constructor must be a call to Questions constructor using super. But you need to process the String before calling super. Do the following
Write two private static methods String parseQ(String) and String parseA(String) These take the constructors parameter and return the computed question/answer as specified above o So parseQ(The sky is _-blue-_) might return The sky is _________ o The __________ should be reasonably long.
Now your constructor might look like public FillInQuestion(String sentence, Diffenum diff) { super(parseQ(sentence), parseA(sentence), diff) on the first line.
If FillInQuestions parameter String does not contain _- and -_ and not in the correct order, throw an IllegalArgumentException. (You can throw this in the parseQ method)
Override Questions copy method. It still must return Question, but it will be creating a FillInQuestion object so that the actual type of the copy is correct.
Modify QuizManager to include at least two FillInQuestions in a quiz.
Write a JUnit test class that tests the constructor and copy methods of the FillInQuestion class are working properly. (The other methods are already tested by the JUnit test class for Question
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started