Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 In this lab you are going to be implementing the inheritance hierarchy shown below. You've already done Quiz and Question Modify your Question

image text in transcribed

image text in transcribed

image text in transcribed

Exercise 1 In this lab you are going to be implementing the inheritance hierarchy shown below. You've already done Quiz and Question Modify your Question class to have a String display0 method that returns a string containing the question and difficulty of the current question. Modify giveQuiz to use this display method when displaying a question to the user. You should not modify Question or Quiz in any other way. Chu Queen quiler heruliuention> SO total ! G C W SENG EGY getTotal ada (Question) void getra() int veQuim w *gives (1.234Int) : veld Question (SUE SE Question(L S 10) 4splay string **Correct(). Boolean 1000 11 Question namin Strington uz hastion (str 1. Ste a unt double +istorzect(String answG). boolman Com ACCAM color in mamma cho wa Exercise 2 Create a class called FillinQuestion that inherits from Question. The constructor should accept 2 parameters, a String called statement that contains both the question and the answer, with the answer surrounded by underscores, as well as an integer representing the difficulty of the 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." You will need to parse the question and the answer out of the single string. Hint: consider writing helper methods. Modify one of your quiz objects in QuizTime.java to contain two FillinQuestions. Exercise 3 Create a class called NumericQuestion that is a child of Question. In this class, the questions will be numeric questions, where if the correct answer and the given answer differ by no more than some value (let's call it the tolerance), accept the response as correct. Hier: ttnk about how you checked which Fish objecr should eat the other. Refer to the UML diagram for more information about this class. Modify one of your quiz objects in QuizTime java to contain two NumericQuestions, Exercise 4 Create a subclass of Question called MultiChoiceQuestion. This class should allow multiple correct choices as answers for a question. The constructor should accept 2 parameters, the question and its difficulty: setting the answer to initially be the empty string This class should contain a method call a ddehoice that accepts a String (a possible answer to the question and a boolean true if it is a correct answer false if it is not and adds the choice to an ArrayList of possible anstrers for the question If it a correct answer the method should update the answer to the question to include the index of this correct answer in the arraylist This class should override the display" method to show the user all the possible answers for a question and give Modify one of your quiz objects in QuizTime.java to contain two NumericQuestions. Exercise 4 Create a subclass of Question called MultiChoice Question. This class should allow multiple correct choices as answers for a question The constructor should accept 2 parameters, the question and its difficulty, setting the answer to initially be the empty string. This class should contain a method call addChoice that accepts a String (a possible answer to the question) and a boolean (true if it is a correct answer, false if it is not) and adds the choice to an ArrayList of possible answers for the question. If it is a correct answer, the method should update the answer to the question to include the index of this correct answer in the artaylist. This class should override the display method to show the user all the possible answers for a question and give the user instructions on how to answer the question. See the UML diagram above and the sample output below for more information Violets are (Difficulty: 1) Correct! 17.2 - 15.1 (Difficulty: 1) Correct! What are correct colors of ants? (Difficulty: 1) 1. black 2. Breen 3 orange Enter all correct choices. For example, if you think 1 and 2 are correct enter 12 Modify one of your quiz objects in QuizTime java to contain two MultiChoice Questions Note: 41 would not be considered a correct answer to the multichoice question in the screenshot above. Exercise 1 In this lab you are going to be implementing the inheritance hierarchy shown below. You've already done Quiz and Question Modify your Question class to have a String display0 method that returns a string containing the question and difficulty of the current question. Modify giveQuiz to use this display method when displaying a question to the user. You should not modify Question or Quiz in any other way. Chu Queen quiler heruliuention> SO total ! G C W SENG EGY getTotal ada (Question) void getra() int veQuim w *gives (1.234Int) : veld Question (SUE SE Question(L S 10) 4splay string **Correct(). Boolean 1000 11 Question namin Strington uz hastion (str 1. Ste a unt double +istorzect(String answG). boolman Com ACCAM color in mamma cho wa Exercise 2 Create a class called FillinQuestion that inherits from Question. The constructor should accept 2 parameters, a String called statement that contains both the question and the answer, with the answer surrounded by underscores, as well as an integer representing the difficulty of the 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." You will need to parse the question and the answer out of the single string. Hint: consider writing helper methods. Modify one of your quiz objects in QuizTime.java to contain two FillinQuestions. Exercise 3 Create a class called NumericQuestion that is a child of Question. In this class, the questions will be numeric questions, where if the correct answer and the given answer differ by no more than some value (let's call it the tolerance), accept the response as correct. Hier: ttnk about how you checked which Fish objecr should eat the other. Refer to the UML diagram for more information about this class. Modify one of your quiz objects in QuizTime java to contain two NumericQuestions, Exercise 4 Create a subclass of Question called MultiChoiceQuestion. This class should allow multiple correct choices as answers for a question. The constructor should accept 2 parameters, the question and its difficulty: setting the answer to initially be the empty string This class should contain a method call a ddehoice that accepts a String (a possible answer to the question and a boolean true if it is a correct answer false if it is not and adds the choice to an ArrayList of possible anstrers for the question If it a correct answer the method should update the answer to the question to include the index of this correct answer in the arraylist This class should override the display" method to show the user all the possible answers for a question and give Modify one of your quiz objects in QuizTime.java to contain two NumericQuestions. Exercise 4 Create a subclass of Question called MultiChoice Question. This class should allow multiple correct choices as answers for a question The constructor should accept 2 parameters, the question and its difficulty, setting the answer to initially be the empty string. This class should contain a method call addChoice that accepts a String (a possible answer to the question) and a boolean (true if it is a correct answer, false if it is not) and adds the choice to an ArrayList of possible answers for the question. If it is a correct answer, the method should update the answer to the question to include the index of this correct answer in the artaylist. This class should override the display method to show the user all the possible answers for a question and give the user instructions on how to answer the question. See the UML diagram above and the sample output below for more information Violets are (Difficulty: 1) Correct! 17.2 - 15.1 (Difficulty: 1) Correct! What are correct colors of ants? (Difficulty: 1) 1. black 2. Breen 3 orange Enter all correct choices. For example, if you think 1 and 2 are correct enter 12 Modify one of your quiz objects in QuizTime java to contain two MultiChoice Questions Note: 41 would not be considered a correct answer to the multichoice question in the screenshot above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+4. What is the history of this situation?

Answered: 1 week ago