tutorial_inheritance-RexReubens-master/.classpath tutorial_inheritance-RexReubens-master/.gitignore /bin/ tutorial_inheritance-RexReubens-master/.project Quiz_tutorial org.eclipse.jdt.core.javabuilder...

1 answer below »
the assignment is in the attached files. I do not need a fully completed assignment I just need a partially completed assignment please just start the project for me, the assignment is only 2 classes in total, I need it as soon as possible.


tutorial_inheritance-RexReubens-master/.classpath tutorial_inheritance-RexReubens-master/.gitignore /bin/ tutorial_inheritance-RexReubens-master/.project Quiz_tutorial org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature tutorial_inheritance-RexReubens-master/README.md # Inheritance_n_Polymorphism In this exercise we are going to practice a few code related to inheritance and polymorphism. We are going to design a **Quizz** where a set of different types of questions like short question, MCQ, true/false will be displayed to the user and will collect response from the user. Also the program will check whether the response is rigth or wrong. # What you have in the starter code - We have a generic class called **Question** that has two member variables **text**, **answer** and a method called **checkAnswer** as described bellow: - **text**: stores the description of the question - **answer**: stores the correct answer for the question - **checkAnswer(String ans)**: That takes the answer as an argument/parameter and checks whether it is correct or not. It returns *true* if the answer matched with the correct answer stored in the variable **answer**, otherwise returns *false*. You also have a **Main** class that demonstrate the use of the **Qustion**. # What you have to do ## Task 1 - Import the project in *eclipse* from the repository. - Run the program and see how it works. - Try to understand the code and what it is doing. ## Task 2 - Create a new class called **MCQQuestion** that extends the class **Question**. - Your **MCQQuestion** class should have the following members: - An ArrayList **choices** to store the list of choices for a question. - A constructor that creates the ArrayList - A method **addChoice(String choice, boolean correct)** that adds choices for a question and stores as the answer for the question if the correct is *true*. - A method **display()** that overrides the display method of the super class to display the MCQ question properly with choices. - Rewrite the **Main** class to display a MCQ question and take a response from keyboard for the answer as the choice (1,2 ..) - Display if the answer is correct or not. - The screen may look like: ``` In which country was the inventor of Java born? 1: Canada 2: United States 3: Denmark 4: United State Your answer: 1 true ``` ## Task 3 - Create a new class called **Quiz** that will store a list of questions. - Add a method called **addQuestion(Question Q)** that can add any type of question in the list. - Add a method called **allQuestions()** that returns the list of questions added to a Quiz. - Rewrite the **Main** class that creates a **Quiz** object and adds at least three different questions with answers in order: first one is a regular question, second one is an MCQ, third one is a regular question and so on (Try to make your questions as difficult as possible). - Now display the questions from the Quiz one at a time and take a respose from the user. - Display whether the result is correct or not. - You may declare any helper method, or getter and setter or constructor if necessary. ## Task 4 - Now change the **Question** class as an Abstract class and change display as an abstract method. - Try to run the program and see what errors you get. - Try to fix those errors. - Now we don't have an inherited method display. - Create a new extended class from **Question** as **ShortQuestion**. - Use this **ShortQuestion** as we used the generic **Question** and rewrite your program. - Try to compile the **ShortQuestion** without overriding the **display()** method. - Write necessary code to fix the errors. tutorial_inheritance-RexReubens-master/src/Inheritance/Main.java tutorial_inheritance-RexReubens-master/src/Inheritance/Main.java package Inheritance; import java.util.ArrayList; import java.util.Scanner; /** This program shows a simple quiz with one question.  */ public class Main {     public static void main(String[] args)     {         Scanner in = new Scanner(System.in);         Question q = new Question();         q.setText("Who was the inventor of Java?");         q.setAnswer("James Gosling");         q.display();         System.out.print("Your answer: ");         String response = in.nextLine();         System.out.println(q.checkAnswer(response));     } } tutorial_inheritance-RexReubens-master/src/Inheritance/Question.java tutorial_inheritance-RexReubens-master/src/Inheritance/Question.java package Inheritance; /** 2 A question with a text and an answer. 3 */ public class Question {     private String text;     private String answer;     /**  Constructs a question with empty question and answer.      */     public Question()     {         text = "";         answer = "";     }     /**  Sets the question text. @param questionText the text of this question      */     public void setText(String questionText)     {         text = questionText;     }     /**  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);     }     /**  Displays this question.      */     public void display()     {         System.out.println(text);     }     //public abstract void display(); }
Answered Same DayFeb 26, 2021

Answer To: tutorial_inheritance-RexReubens-master/.classpath tutorial_inheritance-RexReubens-master/.gitignore...

Aditya answered on Feb 26 2021
145 Votes
tutorialinheritance-rexreubens-master-walzawo1/.project

     tutorialinheritance-rexreubens-master-walzawo1
    
    
    
    
    
    
    
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/.classpath

    
    
    

tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/.gitignore
/bin/
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/.project

     Quiz_tutorial
    
    
    
    
        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/bin/Inheritance/Main.class
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/bin/Inheritance/MCQQuestion.class
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/bin/Inheritance/Question.class
tutorialinheritance-rexreubens-master-walzawo1/tutorial_inheritance-RexReubens-master/README.md
# Inheritance_n_Polymorphism
In this exercise we are going to practice a few code related to inheritance and polymorphism. We are going to design a **Quizz** where a set of different types of questions like short question, MCQ, true/false will be displayed to the user and will collect response from the user. Also the program will check whether the response is rigth or wrong.
# What you have in the starter code
- We have a generic class called **Question** that has two member variables **text**, **answer** and a method
called **checkAnswer** as described bellow:
- **text**: stores the description of the question
- **answer**: stores the correct answer for the question
- **checkAnswer(String ans)**: That takes the answer as an argument/parameter and checks whether it is correct or not. It returns *true* if the answer matched with the correct answer stored in the variable **answer**, otherwise returns *false*.
You also have a **Main** class that demonstrate the use of the **Qustion**.
# What you have to do
## Task 1
- Import the project in *eclipse* from the repository.
- Run the program and see how it works.
- Try to understand the code and what it is doing.
## Task 2
- Create a new class called **MCQQuestion** that extends the class **Question**.
- Your **MCQQuestion** class should have the following members:
- An ArrayList **choices** to store the list of choices for a...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here