1 Star 1 Fork 0

CS-IMIS-23/20172313yukunpeng

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
MiniQuiz.java 1.70 KB
Copy Edit Raw Blame History
余坤澎 authored 7 years ago . docs:example practice
//**********************************************************************
// MiniQuiz.java Author:Lewis/Loftus
//
// Demonstrates the use of a class that implements an interface.
//**********************************************************************
import java.util.Scanner;
public class MiniQuiz
{
//----------------------------------------------------------------------
//Presents a short quiz.
//----------------------------------------------------------------------
public static void main(String []args)
{
Question q1,q2;
String possible;
Scanner scan = new Scanner(System.in);
q1 = new Question("What is the capital of Jamaica?","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);
System.out.print(q1.getQuestion()); System.out.println("(Level:"+q1.getComplexity()+")");
possible = scan.nextLine();
if (q1.answerCorrect(possible))
System.out.println("Correct"); else
System.out.println("No,the answer is " + q1.getAnswer());
System.out.println();
System.out.print(q2.getQuestion());
System.out.println("(Level:" + q2.getComplexity()+")");
possible = scan.nextLine();
if (q2.answerCorrect(possible))
System.out.println("Correct");
else
System.out.println("No,the answer is " +q2.getAnswer()); }
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/20172313yukunpeng.git
git@gitee.com:CS-IMIS-23/20172313yukunpeng.git
CS-IMIS-23
20172313yukunpeng
20172313yukunpeng
master

Search

371d5123 14472233 46e8bd33 14472233