Computers and Technology

Use the Question class from Chapter 7 to define a Quiz class. A quiz can have up to 25 questions (create an array of 25 Question objects within your Quiz class). Define an add method of the Quiz class that adds a question to a quiz. Define a giveQuiz method of the Quiz class to present each question in order to the user, accept an answer, and keep track of the result (whether the answer is correct or incorrect). Define a driver class called QuizTime with a main method that creates a sample quiz with 3 questions (that you create and specify in your program), then presents the quiz to the user and prints the final results. Note you do not need to use the Complexity interface used by the Question class in Chapter 7 for this assignment. An example session in the Console window is given below. Example session
What color was George Washington's white horse?
blue
What's your favorite programming language?
Java
How many moons does the planet Earth have (specify a number)?
1
Correct: 2 Incorrect: 1
// // Question. java Author: Lewis/Loftus // // Represents a question (and its answer). //
public class Question implements Complexity { private String question, answer; private int complexityLevel; // // Constructor: Sets up the question with a default complexity. // public Question(String query, String result) { question = query; answer = result; complexityLevel = 1; } // // Sets the complexity level for this question. // public void setComplexity(int level) { complexityLevel = level; } // // Returns the complexity level for this question. // public int getComplexity() { return complexityLevel; } // // Returns the question. // public String getQuestion() { return question; } // // Returns the answer to this question. // public String getAnswer() { return answer; } // // Returns true if the candidate answer matches the answer. // public boolean answerCorrect(String candidateAnswer) { return answer. equals(candidateAnswer); } // // Returns this question (and its answer) as a string. // public String toString() { return question + "\n" + answer; } }

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:30, 1232444553
Which of the following examples has four beats in each measure?
Answers: 2
image
Computers and Technology, 22.06.2019 17:30, uh8hardiek
Ou listened to a song on your computer. did you use hardware or software?
Answers: 2
image
Computers and Technology, 22.06.2019 22:30, Metlife
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, anggar20
Which tab is used to change the theme of a photo album slide show? a. design b. view c. transitions d. home
Answers: 1
Do you know the correct answer?
Use the Question class from Chapter 7 to define a Quiz class. A quiz can have up to 25 questions (cr...

Questions in other subjects:

Konu
Mathematics, 24.10.2019 01:00