Question: Project Outcomes: Create a Java application that: Implements Object serialization. Implements reading, writing and searching a random access file. Implements API and user defined exceptions.
Project Outcomes:
Create a Java application that:
Implements Object serialization.
Implements reading, writing and searching a random access file.
Implements API and user defined exceptions.
Catches and recovers from thrown exceptions
Develops a program with several classes.
Creates UML class diagrams.
Prep Reading
Absolute Java Chapters 1 - 10
Project Requirements:
In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values.
Project details
Create a class to administer the question bank with the following functionality:
Command line menu.
Stores question data in a Random Access File (See details of file structure below)
Enter new questions including answer and question point value. Point value should be 1 to 5.
Delete questions by searching for a question in the random access file. I would suggest assigning a question id number to each question. (hint: Static variable)
Display all of the questions, associated answers and point value.
The question bank must be stored in a binary Random Access File with the following record structure
Question (@50 bytes) ASCII char use one byte
Answer (@20 bytes)
Question point value (an int)
HINT: Use String.format method for padding
String.format("%" + n + "s", s);
where n is number of spaces and s is the String
Create and use user defined exception to ensure question and answer do not exceed maximum number of bytesand the point value is between 1 and 5(inclusive)
For the purposes of this project the question bank will contain at least 15 questions.
Example of text menu:
Trivia Game Administration 1. List all questions 2. Delete question 3. Add question 4. Quit Enter choice:
Create a class for the players information with the following functionality
Players real name
Players gamer nick name
Current total score. Total score is a summation of all the Players game sessions.
Ability to store the user object to a serialized file, the file name is the user real name such as johnsmith.dat. No need to handle duplicate file names.
Create a class for questions including
question, answer, value and a question ID
Accessor methods to return all instance fields.
Create a class for the trivia game with the following functionality.
Stores a collection of Question objects.
Using random number generation to read 5 questions from the question bank and stores them in the collection. Remember the questions are stored in a record format.
Returns the next question object in the collection.
Evaluate the answer and returns the outcome. The evaluation should ignore case.
Create a class to run the game
Command line
Ask if new or existing user.
If new user create a new user object and ask for required user information(name, nick name)
If existing user
prompt for user name
read user information from serialized file into a user object.
If file not found handle exception robustly by providing error message and asking again.
Create trivia game object
Start the game, the game sequence is
Display a question
Prompt for an answer
Evaluate the answer
Display the evaluation results
Update the users total score
Display the user current game score.
Continue to display new questions until current game is over. (5 questions)
Once game is over, allow user to play again or quit
If user quit
Display his nick name, current game score and total score.
Write or overwrite the current user data to the serialized file.
Allow another user to play or quit the program.
Example text based game run after user determined.
Question 1 Who is the president? Obama That is correct! Your score is 1 Question 2 Who is buried in Grants tomb? Grant That is correct! Your score is 4
Question 3 What is the capital of Connecticut? New Haven Wrong. The correct answer is Hartford Your score is 4
Programmer Design information
As you may have noticed much of the details for this project are left up to you.
You may create any additional classes, methods (especially private utility methods) or instance fields you think may be needed, however you will be graded on good object oriented design, so points will be taken off for unnecessary classes, methods or unused instance fields or instance fields that should be local variables.
There is no need to add any additional functionality such as checking for duplicate questions, or duplicate user files etc, just focus on the required functionality.
Create 2 UML Class Diagram for this project.
Design Version - completed prior to coding the project to assist with coding.
Final Version - completed after the coding that accurately represents the final version of the code.
All instance variables, including type.
All methods, including parameter list, return type and access specifier (+, -);
No need to include the class with main method in the UML diagrams. Refer to the UML Distilled pdf on the content page as a reference for creating class diagrams
Create a detailed plan for the implementation of the current programming project from a conceptual description of the project. (Expand the Cells as needed)
| Step | Step name | Description | It is done when... |
| 1 | |||
| 2 | |||
| ... | |||
| n |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
