subject
Computers and Technology, 27.04.2021 16:10 babas97

Create a class named TriviaGameV1 that plays a simple trivia game. The game should have five questions. Each question has a corresponding answer and point value between 1 and 3 based on the difficulty of the question. TriviaGameV1 will use three arrays. An array of type String should be used for the questions. Another array of type String should be used to store the answers. An array of type int should be used for the point values. All three arrays should be declared to be of size 5. The index into the three arrays can be used to tie the question, answer, and point value together. For example, the item at index 0 for each array would correspond to question 1, answer 1, and the point value for question 1. Manually hardcode the five questions, answers, and point values in the constructor of TriviaGameV1. The five questions and their corresponding answers are shown on page 3. The point values should be set to 1, 2, 2, 3, 1, respectively. The class should also provide the following two public methods:

• public boolean askNextQuestion() - This method takes no argument and returns a boolean. If there are no more questions to ask, it returns false. Otherwise, it asks the next question and gets an answer from the user. If the player’s answer matches the actual answer (case insensitive comparison), the player wins the number of points for that question. If the player’s answer is incorrect, the player wins no points for the question and the method will show the correct answer. It returns true after Q & A have been processed.
• public void showScore() - This method takes no argument and returns void. It displays the current score the player receives thus far.

The test driver is provided below, which creates a TriviaGameV1 object. After the player has answered all five questions, the game is over.

public class TriviaGameV1Test {
public static void main(String[] args) { TriviaGameV1 game = new TriviaGameV1();
while (game. askNextQuestion()) game. showScore(); System. out. println("Game over! Thanks for playing!"); }
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:20
Write a method replacekey in the minheap class with the following signature: public void replacekey(integer oldkey, integer newkey) the method will replace the first occurrence of oldkey with the newkey, and restore the min-heap property after the change. if the oldkey does not exist in the heap, the method prints an appropriate message and returns without changing the heap. example: suppose our binary heap object (bh) has the following keys: *** 4 6 7 32 19 64 26 99 42 54 28 then the method call: bh.replacekey (oldkey integer(54), newkey integer(2))
Answers: 1
question
Computers and Technology, 22.06.2019 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation paint desktop publishing
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
question
Computers and Technology, 23.06.2019 05:00
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
You know the right answer?
Create a class named TriviaGameV1 that plays a simple trivia game. The game should have five questio...
Questions
question
Mathematics, 26.09.2019 02:30
Questions on the website: 13722363