import java.io.*; public class Doctor { public static void main(String [] args) throws IOException { Doctor dr=new Doctor(); dr.talk(System.in,System.out);//System 类中in为InputStream,out 为 OutStream类型 } void talk(InputStream in,OutputStream out) throws IOException { BufferedReader rd=new BufferedReader( new InputStreamReader(in)); PrintWriter pw=new PrintWriter( new OutputStreamWriter(out),true); pw.println("Hello,I am a Robot-Doctor,I know many things,what are you want to know?"); while(true) { String question=rd.readLine(); reply(pw,question); } } void reply(PrintWriter pw,String question) throws IOException { if(0==question.compareTo("I love you,Miss Ma!")) pw.println("I love you,too"); else if(question.compareTo("Who are you?")==0) pw.println("I am Dactor Ma!"); else if(0==question.compareTo("1+1=")) pw.println("haha ,I know,It's 2!"); else pw.println("I am sorry!I don't know what You said! "+question+" what's it meas!!! mm mm..."); } }
public class Doctor
{
public static void main(String [] args) throws IOException
{
Doctor dr=new Doctor();
dr.talk(System.in,System.out);//System 类中in为InputStream,out 为 OutStream类型
}
void talk(InputStream in,OutputStream out) throws IOException
{
BufferedReader rd=new BufferedReader(
new InputStreamReader(in));
PrintWriter pw=new PrintWriter(
new OutputStreamWriter(out),true);
pw.println("Hello,I am a Robot-Doctor,I know many things,what are you want to know?");
while(true)
{
String question=rd.readLine();
reply(pw,question); } }
void reply(PrintWriter pw,String question) throws IOException
{
if(0==question.compareTo("I love you,Miss Ma!"))
pw.println("I love you,too");
else if(question.compareTo("Who are you?")==0)
pw.println("I am Dactor Ma!");
else if(0==question.compareTo("1+1="))
pw.println("haha ,I know,It's 2!");
else pw.println("I am sorry!I don't know what You said! "+question+" what's it meas!!! mm mm..."); }
}