{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz - public void add(Question newQuestion if(current<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Quiz.java Author: Lewis/Loftus // // Solution to Programming Project 6.10 // //******************************************************************** / import java.util.Scanner; i public class Quiz { private final int MAX_QUESTIONS = 25; private Question[] questions; private int current; private int correct; private int incorrect; public Quiz() { questions = new Question[MAX_QUESTIONS]; current = 0; correct = incorrect = 0;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public void add(Question newQuestion) { if (current < MAX_QUESTIONS) questions[current++] = newQuestion; } public void giveQuiz() { Scanner sc = new Scanner (System.in); for (int i = 0; i < current; i++) { System.out.println(questions[i].getQuestion()); if (questions[i].answerCorrect(sc.nextLine())) correct++; else correct--; } } public int getNumCorrect() { return correct; } public int getNumIncorrect() { return incorrect; } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online