Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Program Topics: abstract class, interface, package, serializable, factory design pattern The Problem Suppose you are a software engineer working for a small software consulting

Java Program

Topics: abstract class, interface, package, serializable, factory design pattern

The Problem

Suppose you are a software engineer working for a small software consulting company called J Software. A high school has contracted your company to computerize their tests. Your company would provide software for the client to create tests that students can take on computers. Your project lead has analyzed the requirements and came up with some Java interfaces for type of questions the program must support and has assigned to you to implement the solution. The implementation of the interfaces will also be used to created the two programs that will be used by the school. The first program is for creating questions for tests and the second program is for administering the tests to students.

The Interfaces

The interface code is posted on blackboard. Download them and add them to your NetBeans project. Below are the interfaces provided for you:

Type of questions interfaces

o IMultipleChoiceQuestion

o ITrueFalseQuestion

o IFillInBlanksQuestion

o IShortAnswerQuestion

o IQuestion

Question set and question factory interfaces

o IQuestionSet (a collection of questions)

o IQuestionFactory (a factory to creating questions)

image text in transcribed

The IQuestionSet represents a collection of questions which serves as a test. For example, a user may create a set of questions named Midterm that has 20 questions in Java. The number of questions supported depends on the implementation.. For this exercise, you should use ArrayList as it will simplify the coding. The UML diagram above shows the operations IQuestionSet supports. You will use Serializable interface to support saving your question set.

To encourage you from using the implementation classes directory, you will implement the IQuestionFactory. The factory knows how to create the questions. Your program does not care what the name of the classes of the questions are. It only cares about the method provides by the interfaces. This is the concept of abstraction.

The interfaces should guide you in your implementation of the interfaces. The interfaces contain comments that describe what it is and what each method does. You will find the interfaces in the package com.jsoftware.test.api. You will add your implementation of the interfaces in the package com.jsoftware.test.impl.

The Programs

You will write two console programs that uses the interfaces and your implementation. The first program is named TestMaker which allows users to create test. The second program is named TestTaker lets a user loads an existing test and take it. The sample runs show how each program behaves. These programs should be in the package com.jsoftware.test.

To prevent your programs from being dependent on the question implementation, the only class it should know about is the question factory implementation. That makes your program very independent from the implementation. Changes to the names of implementation classes will not affect your program as it doesnt even care about their constructors. This makes your program much more maintainable.

The solution should implement multiple-choice question, true false question, fill in the blank question, short answer question question factory, and question set. Your program must compile and execute.

Provided code below:

IMultipleChoiceQuestion code:

image text in transcribed

ITrueFalseQuestion code:

image text in transcribed

IFillInBlanksQuestion code:

image text in transcribed

IShortAnswerQuestion code:

image text in transcribed

IQuestion code:

image text in transcribed

IQuestionSet code:

image text in transcribed

image text in transcribed

IQuestionFactory Code:

image text in transcribedimage text in transcribed

My run on net beans:

Sample run for Test Maker program:

image text in transcribedimage text in transcribedimage text in transcribed

Sample run for Test Taker:

image text in transcribedimage text in transcribed

Test taker sample run:

image text in transcribed

> A QuestionFactory O+IQuestion makeMultipleChoice(String question, Stringl choices, int answer) O+IQuestion makeTrueFalse(String question, boolean answer) O+IQuestion makeFill inBlank(String question, String answers) O+IQuestion makeShortAnswer(String question, StringD keywords) O+IQuestionSet load(String filename) O+boolean save(lQuestionSet testSet, String filename) +1 QuestionSet makeEmptyTestSet0 > o Question ..1-> 0+String getQuestiono > o IQuestionSet O +lQuestionSet emptyTestSet0 +IQuestionSet randomSample(int size) o+boolean add(IQuestion question) > > FilllnBlanksQuestion o+boolean checkAnswer(StringD keywords) o IMultipleChoiceQuestion +boolean remove(int index) O+IQuestion getQuestion(int index) O+int size0 -boolean checkAnswer(int index) > > o IShortAnswerQuestion oITrueFalseQuestion O+boolean checkAnswer(String answer) O+boolean checkAnswer(boolean answer) > A QuestionFactory O+IQuestion makeMultipleChoice(String question, Stringl choices, int answer) O+IQuestion makeTrueFalse(String question, boolean answer) O+IQuestion makeFill inBlank(String question, String answers) O+IQuestion makeShortAnswer(String question, StringD keywords) O+IQuestionSet load(String filename) O+boolean save(lQuestionSet testSet, String filename) +1 QuestionSet makeEmptyTestSet0 > o Question ..1-> 0+String getQuestiono > o IQuestionSet O +lQuestionSet emptyTestSet0 +IQuestionSet randomSample(int size) o+boolean add(IQuestion question) > > FilllnBlanksQuestion o+boolean checkAnswer(StringD keywords) o IMultipleChoiceQuestion +boolean remove(int index) O+IQuestion getQuestion(int index) O+int size0 -boolean checkAnswer(int index) > > o IShortAnswerQuestion oITrueFalseQuestion O+boolean checkAnswer(String answer) O+boolean checkAnswer(boolean answer)

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

l Identify the three different roles of HR management.

Answered: 1 week ago