package com.isannian;
/**
* @author isannian
* 猜谜程序
* 程序分析:
* 1)问题是什么? 猜 谜语 迷题---答案
* 2)怎样使用这个程序的? 出题---解答---答案
* 3)程序运行时有哪些行为? 获取问题---获取答案
* 细分:
*
*/
import java.util.*;
public class RiddleTest
{
public static void main(String[] args)
{
Riddle riddle =new Riddle();
riddle.getQuestion();
System.out.println(riddle.getQuestion());
Scanner s =new Scanner(System.in);
System.out.print("请输入答案:");
String s1 =s.next();
//s.close();
//riddle.getAnswer();
if(s1.equals(riddle.getAnswer()))
{
System.out.println("答案正确"+s1);
}
else{
System.out.println("答案错误!请重新答题");
}
}
}
class Riddle
{
private String question = "???????///";
private String answer ="abcd";
public Riddle()
{
}
public Riddle(String question,String answer)
{
this.question=question;
this.answer=answer;
}
public String getQuestion()
{
return question;
}
public String getAnswer()
{
return answer;
}
}
riddle
最新推荐文章于 2022-12-05 14:22:52 发布