Reference no: EM13950475 
                                                                               
                                       
Add a method addText to the Question class, and provide a different implementation of ChoiceQuestion that calls addText rather than storing an array list of choices.
Here is a sample program run:
Who was the inventor of Java?
Your answer:
James Gosling
true
In which country was the inventor of Java born?
1: Australia
2: Canada
3: Denmark
4: United States
Your answer:
2
true
Use the following class as your main class:
import java.util.Scanner;
public class QuestionDemo
{
public static void main(String[] args)
{
Question[] quiz = new Question[2];
quiz[0] = new Question("Who was the inventor of Java?");
quiz[0].setAnswer("James Gosling");
ChoiceQuestion question = new ChoiceQuestion(
"In which country was the inventor of Java born?");
question.addChoice("Australia", false);
question.addChoice("Canada", true);
question.addChoice("Denmark", false);
question.addChoice("United States", false);
quiz[1] = question;
Scanner in = new Scanner(System.in);
for (Question q : quiz)
{
q.display();
System.out.println("Your answer: ");
String response = in.nextLine();
System.out.println(q.checkAnswer(response));
}
}
}
Complete the following classes in your solution:
/**
A question with multiple choices.
*/
public class ChoiceQuestion extends Question
{
// Add any needed instance variables, but don't store the choices
// The choices should be added to the text of the superclass
/**
Constructs a choice question with a given text and no choices.
@param questionText the text of this question
*/
public ChoiceQuestion(String questionText)
{
...
}
/**
Adds an answer choice to this question.
@param choice the choice to add
@param correct true if this is the correct choice, false otherwise
*/
public void addChoice(String choice, boolean correct)
{
...
}
}
/**
A question with a text and an answer.
*/
public class Question
{
private String text;
private String answer;
/**
Constructs a question with a given text and an empty answer.
@param questionText the text of this question
*/
public Question(String questionText)
{
text = questionText;
answer = "";
}
/**
Sets the answer for this question.
@param correctResponse the answer
*/
public void setAnswer(String correctResponse)
{
answer = correctResponse;
}
/**
Checks a given response for correctness.
@param response the response to check
@return true if the response was correct, false otherwise
*/
public boolean checkAnswer(String response)
{
return response.equals(answer);
}
/**
Add a line of text to the question text.
*/
public void addLine(String line)
{
...
}
/**
Displays this question.
*/
public void display()
{
System.out.println(text);
}
}
                                       
                                     
                                    
	
		| 
                                   
                                    
                                        
                                           Existing product and identify its target market
                                        : Select an existing product and identify its target market. Describe how  each variable of the marketing mix (product, price, place, and  promotion) is being executed. Address at least three elements of each  variable.Focus of The Marketing Mix 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           Determine the exergetic efficiency
                                        : For the turbine-compressor arrangement of Problem 6.164, determine the  exergetic efficiency for (a) the turbine, (b) the compressor, (c) an  overall control volume enclosing the turbine and compressor. Let T0 5 300 K. 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           What are the time and space requirements for computing t(n)
                                        : The following recurrence equation gives the expected number of  comparisons for Quicksort, given that the "pivot element" is selected  uniformly at random from the list: 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           Effects of motion and gravity
                                        : A pump operating at steady state takes in saturated liquid water at 65  lbf/in.2 at a rate of 10 lb/s and discharges water at 1000 lbf/in.2 The  isentropic pump efficiency is 80.22%. Heat transfer with the  surroundings and the effects of motion and .. 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           In which country was the inventor of java born
                                        : Add a method addText to the Question class, and provide a different  implementation of ChoiceQuestion that calls addText rather than storing  an array list of choices. 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           Description of the actions you would take in this situation
                                        : Description of the actions you would take in this situation, and why.  Justify these actions by referencing appropriate laws, ethical  standards, and professional guidelines 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           Discuss sharing economy from a supply and demand standpoint
                                        : Discuss the sharing economy from a supply and demand standpoint. How do  companies like Uber and Airbnb affect supply and demand in the markets  for shared rides (taxis, limos, etc.) and rented rooms, respectively? 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           Domestic water heating with conventional electrical
                                        : Tankless microwave water heating systems have been introduced that not  only quickly provide hot water but also significantly reduce the exergy  destruction inherent in domestic water heating with conventional  electrical and gas- fueled water heater.. 
                                          
                                  
                                     | 
	
		| 
                                   
                                    
                                        
                                           How many bit strings of length 8 are palindromes
                                        : How many bit strings of length 6 is there that begin with 0 or end with a 1? 
                                          
                                  
                                     |