⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doctor.java

📁 可以与精神病人对话的机器人医生。 在命令行中运行
💻 JAVA
字号:
package doctor1;
import java.io.*;

public class Doctor {

	public static void main(String[] args) throws IOException {
		Doctor dr = new Doctor();
		try {
			while (true) {
				dr.talk(System.in, System.out);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	void talk(InputStream in, OutputStream out) throws IOException {
		PrintWriter pw = new PrintWriter(out);
		
		InputStreamReader ir = new InputStreamReader(in);
		BufferedReader br = new BufferedReader(ir);
		String question = br.readLine();
		reply(pw, question);
		
	}

	void reply(PrintWriter pw, String question) throws IOException {
		if (question.equals("I love you,Miss Ma!")) {
			pw.println("I love you,too");
			pw.flush();
		}
		else if (question.equals("Who are you?")) {
			pw.println("I am Dactor Ma!");
			pw.flush();
		}
		else if (question.equals("1+1=")) {
			pw.println("haha ,I know,It's 2!");
			pw.flush();
		}
		else {
			pw.println("I am sorry!I don't know what You said!"
					+ question + " what's it means!!! mm mm...");
			pw.flush();
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -