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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:00, TamB01
How can i clip a picture to a question on the computer?
Answers: 1
image
Computers and Technology, 23.06.2019 23:30, ayjahj
What can you prevent issues related to downloading content form the internet
Answers: 1
image
Computers and Technology, 24.06.2019 12:50, neptunesx
Write a new lc-3 trap subroutine (i. e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i. e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e. g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e. g. b0000 0000 0000 0111 =
Answers: 3
image
Computers and Technology, 24.06.2019 15:00, firdausmohammed80
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
Create a class named TriviaGameV1 that plays a simple trivia game. The game should have five questio...

Questions in other subjects: