📄 discussion.java
字号:
package ijp.assignment1.chat;
/**
* A helper class to test the functionality of ChatBots, used in AIJP assignment 1.
* Runs a conversation between two chat bots for a specified number of
* conversational turns
* @author Judy Robertson
*/
public class Discussion {
/**
* The ChatBot who will start the conversation
*/
private ChatBot initiator;
/**
* The ChatBot who will respond to the initiator
*/
private ChatBot responder;
/**
* Creates a Discssion between two ChatBots and makes them have a conversation
*
*/
public Discussion(){
initiator=new ChatBot();
responder=new ChatBot();
String initiatorName=null;
String responderName=null;
String intiatorDescription=null;
String responderDescription=null;
// Set the names and their own description of the two chatbot
initiator.setName("Bob");
responder.setName("Ann");
initiator.setDescription("Take a chance, make a change");
responder.setDescription("I hate hown po ppl,plz stay away from me if you r hown po!! ");
initiatorName=initiator.getName();
responderName=responder.getName();
intiatorDescription=initiator.getDescription();
responderDescription=responder.getDescription();
String startSentence=null;
String reply=null;
//Start a conversation sentence and print it out then transfer this start sentence as a parameter
//to the responder to generate a random reply
startSentence=initiator.startConversation();
reply=responder.reply(startSentence);
System.out.print(initiatorName);
System.out.print(":");
System.out.print(intiatorDescription);
System.out.println(" ");
System.out.print(">");
System.out.println(startSentence);
System.out.print(responderName);
System.out.print(":");
System.out.println(responderDescription);
System.out.print(">");
System.out.println(reply);
System.out.println(" ");
}
/**
* Create a Discussion for testing functionality of the ChatBot class
*
* @param args
*/
public static void main(String[] args) {
Discussion fiveDiscussion=new Discussion();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -