This preview shows pages 1–2. Sign up to view the full content.

//******************************************************************** // Quiz2.java Author: Lewis/Loftus // // Solution to Programming Project 6.11 // //******************************************************************** / import java.util.Scanner; i public class Quiz2 { private final int MAX_QUESTIONS = 25; private Question[] questions; private int current; private int correct; private int incorrect; public Quiz2() { questions = new Question[MAX_QUESTIONS]; current = 0; correct = incorrect = 0; } 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());

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (questions[i].answerCorrect(sc.nextLine())) correct++; else correct--; } } public void giveQuiz(int minComplexity, int maxComplexity) { Scanner sc = new Scanner (System.in); for (int i = 0; i < current; i++) { int complexity = questions[i].getComplexity(); if (complexity >= minComplexity && complexity <= maxComplexity) { System.out.println(questions[i].getQuestion()); if (questions[i].answerCorrect(sc.nextLine())) correct++; else correct--; } } if (correct == 0 && incorrect == 0) System.out.println("Sorry, no questions fall within the specified complexity range"); } public int getNumCorrect() { return correct; } public int getNumIncorrect() { return incorrect; } }...
View Full Document