MiniQuiz - "Kingston");...

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

View Full Document Right Arrow Icon
//******************************************************************** // MiniQuiz.java Author: Lewis/Loftus // // Demonstrates the use of a class that implements an interface. //******************************************************************** import java.util.Scanner; public class MiniQuiz { private static Scanner scan = new Scanner(System.in); //----------------------------------------------------------------- // Presents a short quiz. //----------------------------------------------------------------- public static void main (String[] args) { Question q1, q2; q1 = new Question ("What is the capital of Jamaica?",
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: "Kingston"); q1.setComplexity (4); q2 = new Question ("Which is worse, ignorance or apathy?", "I don't know and I don't care"); q2.setComplexity (10); askQuestion(q1); askQuestion(q2); } private static void askQuestion(Question question) { String possible; System.out.print (question.getQuestion()); System.out.println (" (Level: " + question.getComplexity() + ")"); possible = scan.nextLine(); if (question.answerCorrect(possible)) System.out.println ("Correct"); else System.out.println ("No, the answer is " + question.getAnswer()); } }...
View Full Document

Ask a homework question - tutors are online