Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Question class is an abstract class: it contains the common features of the other two question classes. You wouldn't instantiate this class but you

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

The Question class is an abstract class: it contains the common features of the other two question classes. You wouldn't instantiate this class but you could use it as a type (e.g. to contain an array of question objects). The TFQuestion class models a True-False type of question, which always has a boolean answer of true or false: this is the question's correct answer. For example, you might want to add the question "Java is an Object Oriented language." to your test bank so you'd have a question text of "Java is an Object Oriented language." and the answer would be stored as true (because that is a true statement). The SAQuestion class models a short-answer type of question, that is simply a question that has a short, String answer. For example, "What is the name of the person who invented the Java programming language?" The question text would be "What is the name of the person who invented the Java programming language?" and the String answer would be "James Gosling" becuase that's the actual correct answer to this question. - Has a questionld data member (int) that must be greater than 0. - Has a String questionText data member that is set to "TBD" (To Be Determined) when an empty Question object is created, but should not ever be an empty String when set by the programmer. - Has accessor and mutator methods for both data members. The mutator methods should throw an IllegalArgumentException with a clear and userfriendly message if the parameter is invalid. - Has a default constructor that sets the ID to 1 and the question text to "TBD". - Has a 2-param constructor that sets the question ID and the question text to programmer-specified values.. - Has an abstract isCorrect(Object guess) method that returns a boolean value. This method will be overridden in each of the child classes. - Has a toString() method that returns the question id and the question text in the form: \#XXX: This is the question text for this question. (where XXX is the question ID and "This is the question text for this question." is the actual question text value). If the question text hasn't been entered yet (its value will be "TBD" then the question text should be displayed as "No question text entered." TFQuestion - Has a data member called answer (boolean) for the true or false answer to the question. - Has accessor and mutator methods for the answer data member (no validation is required). The default value is false. - Has a default constructor that sets the default values for id, text, and answer. - Has a 3-param constructor that sets the values for the programmerspecified id, question text, and answer. - Overrides the isCorrect(Object guess) method to return true if the guess and the answer are the same, and false otherwise. The programmer using this method could pass in a Boolean or a String, so it should work with either one. If the programmer passes in something that's not a Boolean or String, isCorrect() should return false. Case doesn't matter. - Overrides the toString() method to return a String representation of the TF question in the form \#XXX: This is the question text for this question. [true or false?] - Has a String data member for the answer to the question. When an empty SAQuestion object is created, this data member defaults to "TBD". This data member may not be a null-string. - Has an accessor and mutator method for the answer data member. The mutator should throw an IllegalArgumentException with a clear and userfriendly message if the answer value is invalid. - Has a default constructor that sets the default values for question id, question text, and answer. - Has a 3-param constructor that sets the id, question text, and answer to programmer-specified values. - Overrides the isCorrect(Object guess) method to return true if the object's string value is the same as the answer data member's value, and false otherwise. You don't have to worry about the type of object being passed in if you code this correctly (hint: compare the guess's string value to the answer value - it will be a match or not, regardless of what kind of object guess ends up being). This is a case-insensitive match. - Overrides the toString() method to return a String representation of this question in the form \#XXX: This is the question text for this

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_2

Step: 3

blur-text-image_3

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 Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions