Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Assignment 1. Download pa5.zip, extract the NetBeans project folder Pa5 from it, then open it in NetBeans. 2. Examine the class TrueFalseQuestion. Note that

Programming Assignment

1. Download pa5.zip, extract the NetBeans project folder Pa5 from it, then open it in NetBeans.

2. Examine the class TrueFalseQuestion. Note that it (a) has a protected String field questionText and a private boolean answer. (b) has a constructor that assigns an initial value to the field questionText. (c) contains four methods, one to set the question text, one to return a string containing the question with instructions, a final method to set the answer and a final method to check an answer against the set answer.

3. Create code in class Pa5 to demonstrate the use of an object of type TrueFalseQuestion class as a data type. (See the example run for ideas.)

4. Create a class to manage a simple test question. This class (a) inherits class TrueFalseQuestion . (b) must contain a constructor or constructors that use super to call the constructor of class TrueFalseQuestion. (c) must use overriding polymorphism to override the inherited method getQuestion so that the string returned is appropriate for a question needing a string answer instead of a boolean answer. (d) must use overloading polymorphism to create appropriate versions of methods setAnswer and checkAnswer. (e) may contain any other methods or fields (data members) needed.

5. Create code in class Pa5 to demonstrate that your simple test question class is an effective data type. (See the example run for ideas.) CMPS 260 Spring 2018 Programming Assignment #5 2

6. Create a class to manage a multiple choice type question. This class (a) inherits class TrueFalseQuestion (b) must contain a default constructor that uses super to call the constructor of class TrueFalseQuestion and sets the number of answer choices to a fixed number greater than 1. (c) must contain a parametrized constructor that uses super to call the constructor of class TrueFalseQuestion and sets the number of answer choices to that of a passed parameter, but only if the value of the parameter is greater than 1. (d) must use overriding polymorphism to override the inherited method getQuestion so that the string returned is appropriate for a question needing a string answer instead of a boolean answer. (e) must use overloading polymorphism to create appropriate versions of methods setAnswer and checkAnswer. (f) may contain any other methods or fields (data members) needed. Suggested methods include a method for adding a choice to the list of multiple guess choices, returning the maximum number of multiple guess choices and returning the current number of multiple guess choices.

7. Create code in class Pa5 to demonstrate that your multiple choice test question class is an effective data type. (See the example run for ideas.) Requirements No changes are allowed to class TrueFalseQuestion. All programmer created classes must be in separate files, i. e. each programmer created class must be the only class in its file. All user I/O is to occur in class Pa5. User I/O is not allowed in the classes that inherit class TrueFalseQuestion. I. e. there can be no code that accepts input from the user and or sends output to the user in TrueFalseQuestion, simple question or the multiple choice question classes. Tips Write and test the code to demonstrate the use of a TrueFalseQuestion object in Pa5 first. Of the two classes to be created, write the simple question class first and test it by writing the simple class solution code. Then tackle the choice question class. Adding to a string results in a chance of line when that string is output.

image text in transcribed

image text in transcribed

ES Pa5.java xl-TrueFalseQuestion.java >

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

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions