On this page:
1 Questions in a questionnaire
How to submit
7.7

Assignment 5: Using Java built-in Lists

Related files:
  LikertResponseOption.java     Questionnaire.java  

Goals: Practice using Java’s existing classes to implement various list operations.

1 Questions in a questionnaire

Many online questionnaire tools like SurveyMonkey, Doodle Poll, etc. (even Blackboard) allow creating a questionnaire made of several types of questions: Yes/No, Short-answer, Likert scale, etc. In this assignment, you will write classes that represent different types of questions, and a class to represent a questionnaire.

Each question, irrespective of type, has the following common aspects:

The types of questions are:

  1. YesNo: this can be answered in one of two ways: yes or no. answer(String) would accept "Yes" or "No" as valid answers, but case-insensitive, so "yes" or "NO" would also be valid.

  2. ShortAnswer: this can be answered in at most 280 characters, including spaces.

  3. Likert: this can be answered on a fixed, 5-point Likert scale (Strongly Agree, Agree, Neither Agree nor Disagree, Disagree, Strongly Disagree). answer(String) would accept only these precise words as valid answers, but again case-insensitive.

All code for this assignment should be in the cs5004.questionnaire package.

Design an interface Question to represent a question, with the methods listed. Then design the implementing classes YesNo, ShortAnswer, and Likert. Each of those classes should have a constructor that takes in the question prompt as a String and a boolean where true means the question is required, and false means optional. The answer() method in each of these classes will enforce the answer requirements for that question type. Consider using the equalsIgnoreCase() method on the String class to check for case-insensitive String equality. We have supplied you with an enum definition representing the Likert response options. (Not all aspects of this enum are relevant for this assignment.) Note that you can get the values of an enum as an array using the static values() method on the class, such as LikertResponseOption.values().

We have supplied you with an interface Questionnaire, representing a collection of questions. Implement this interface in a class called QuestionnaireImpl, that has only a no-argument constructor. Within this QuestionnaireImpl class, you must make use of Java’s built-in List<T> interface and a built-in implementaiton of List<T>.

Write tests for both the Question and the Questionnaire interface, to ensure that they work correctly in a range of situations. Do not modify any of the given code (except for style fixes should they be necessary).

How to submit
  1. Create a zip file that contains directly your src and test folders. When you unzip the file, you should see only these two folders.

  2. Log on to the Bottlenose submission server.

  3. Navigate to Assignment 5 and submit the zip file.

  4. Wait for a few minutes for feedback to appear, and take action if needed.