Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COSC 211 MP3 (I/O files) Due 02/22/2023 50 points Create a Java class named Trivia that contains three instance variables, question of type String that

COSC 211 MP3 (I/O files) Due 02/22/2023 50 points Create a Java class named Trivia that contains three instance variables, question of type String that stores the question of the trivia, answer of type String that stores the answer to the question, and points of type integer that stores the points value between 1 and 3 based on the difficulty of the question. Also create the following methods: 1. getQuestion( ) it will return the question. 2. getAnswer( ) it will return the answer. 3. getPoints( ) it will return the point 4. setQuestion( String ) sets the value of the question variable 5. setAnswer( String ) sets the value of the answer variable 6. setPoints( int ) sets the value of the points variable 7. Constructor to initialize the instance variables. 8. Overload Constructor to set the instance variables. 9. Add any other methods you need such as equal( ), toString( ), display( ), calcPoints( )... Create Java application that contains a main method that plays a simple Trivia game. The game should have 5 questions. Each question has a corresponding answer and point value between 1 and 3. Implement the game using an array of 5 Trivia objects. Next, open a binary file and store those 5 Trivia objects into a binary file then close the file. Open the file again to read each question one at a time and store them into an array of objects. Randomly, display a question and allow the player to enter an answer. If the players answer matches the actual answer, the player wins the number of points for that question. If the players answer is incorrect, the player wins no points for the question. Make sure the answer is not case sensitive and it is only one word or two words at most. The program should show the correct answer if the player is incorrect. After the player has answered all five questions, the game is over and your program should display the players total score. You need to turn in the code, a sample output of those 5 questions, the player's answers and the total.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions