Answered step by step
Verified Expert Solution
Question
1 Approved Answer
could you please write it in java? Question 2: (FillinTheBlank.java, Quiz.java, QuizTester.java) You have received a communication on an encoded channel there is an alien
could you please write it in java?
Question 2: (FillinTheBlank.java, Quiz.java, QuizTester.java) You have received a communication on an encoded channel "there is an alien infiltrator on board the Equinox. We must determine who it is!". Alarmed, but resolute, you have been assigned the task of creating a series of questions designed to reveal the impostor. Consider the following aggregation relationship: Quiz -numuestions ; int -title : String -quizPillInTheBlank You are given the FillinTheBlank class which defines a fill-in-the- blank-type quiz question (alien impostors are terrible at fill-in-the- blanks). Spend a few moments going over this class to understand how it works. A short tester class has also been provided to show you how it works. Add a copy constructor to this class that makes it easy to duplicate an existing question. Write JavaDocs for the FillinTheBlank class. +Quiz() +Quiz (numQuestions : int, title : String) +Quiz(in : Quiz) +setTitle(title : String): +getTitle() : String +setQuestion(index: int, questionin: FillInTheBlank) : +qet questionindexint) FillInTheBlank +print Text(). +printAnswers) +toString() 1 String Next, write a Quiz class that is made up of FillinTheBlank questions. The UML of this class is given. -question : String -answer : String +FillInTheBlank in FillInTheBlank) +setAnswer : String) A few hints: numQuestions simply keeps track of how many total questions make up Quiz. FillInTheBlank The default constructor creates a quiz with 5 empty questions (nulls) and a title of your choosing. printTest() should display the title of the test and then all the +FillInTheBlanki : String, ai String) test questions (with question numbers) and printAnswers() +set Question(g : String): should display only the answers (with question numbers). IF one of the questions has not yet been answered (i.e., it's still +getQuestion() : String null in the array) do not print anything. You can use an if +toString() 1 String statement to test for nulls. Try it out. setQuestion() and getQuestion() should make sure that the index numbers are appropriate and if not should do nothing. .toString() simply prints the quiz title and the number of questions the quiz can hold. Be sure to use DEEP COPY and DEEP RETURN where appropriate. If anything else is vague or uncertain use the discussion forum! My Quiz class is 75 lines without comments and with liberal spacing and curly braces. +qetAnswer() String Scanners should only appear in your tester class. Write JavaDocs for the Quiz class. Finally write a quiz tester class that creates a simple 5 question quiz. Your tester should allow the user to create the questions. When the quiz has been created use the printTest() and printAnswers() methods to display the results. No output is shown here. Be creative, be polite (to your users) and if you want to compare and contrast program output use the discussion forum. Badge Bonus: After you've done the work above in the tester, create a second quiz using your quiz copy constructor. For your second (copied) test, swap the first and last questions and for the middle question change the question AND the answer (do this by access the question's set methods, not by replacing the question). Finally, print the two tests and two answer sets to show that they are distinct and that the changes to one do not affect the other (i.e., your deep copy is working). Question 2: (FillinTheBlank.java, Quiz.java, QuizTester.java) You have received a communication on an encoded channel "there is an alien infiltrator on board the Equinox. We must determine who it is!". Alarmed, but resolute, you have been assigned the task of creating a series of questions designed to reveal the impostor. Consider the following aggregation relationship: Quiz -numuestions ; int -title : String -quizPillInTheBlank You are given the FillinTheBlank class which defines a fill-in-the- blank-type quiz question (alien impostors are terrible at fill-in-the- blanks). Spend a few moments going over this class to understand how it works. A short tester class has also been provided to show you how it works. Add a copy constructor to this class that makes it easy to duplicate an existing question. Write JavaDocs for the FillinTheBlank class. +Quiz() +Quiz (numQuestions : int, title : String) +Quiz(in : Quiz) +setTitle(title : String): +getTitle() : String +setQuestion(index: int, questionin: FillInTheBlank) : +qet questionindexint) FillInTheBlank +print Text(). +printAnswers) +toString() 1 String Next, write a Quiz class that is made up of FillinTheBlank questions. The UML of this class is given. -question : String -answer : String +FillInTheBlank in FillInTheBlank) +setAnswer : String) A few hints: numQuestions simply keeps track of how many total questions make up Quiz. FillInTheBlank The default constructor creates a quiz with 5 empty questions (nulls) and a title of your choosing. printTest() should display the title of the test and then all the +FillInTheBlanki : String, ai String) test questions (with question numbers) and printAnswers() +set Question(g : String): should display only the answers (with question numbers). IF one of the questions has not yet been answered (i.e., it's still +getQuestion() : String null in the array) do not print anything. You can use an if +toString() 1 String statement to test for nulls. Try it out. setQuestion() and getQuestion() should make sure that the index numbers are appropriate and if not should do nothing. .toString() simply prints the quiz title and the number of questions the quiz can hold. Be sure to use DEEP COPY and DEEP RETURN where appropriate. If anything else is vague or uncertain use the discussion forum! My Quiz class is 75 lines without comments and with liberal spacing and curly braces. +qetAnswer() String Scanners should only appear in your tester class. Write JavaDocs for the Quiz class. Finally write a quiz tester class that creates a simple 5 question quiz. Your tester should allow the user to create the questions. When the quiz has been created use the printTest() and printAnswers() methods to display the results. No output is shown here. Be creative, be polite (to your users) and if you want to compare and contrast program output use the discussion forum. Badge Bonus: After you've done the work above in the tester, create a second quiz using your quiz copy constructor. For your second (copied) test, swap the first and last questions and for the middle question change the question AND the answer (do this by access the question's set methods, not by replacing the question). Finally, print the two tests and two answer sets to show that they are distinct and that the changes to one do not affect the other (i.e., your deep copy is working)
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