ChatBot class:
A chatbot is a computer program designed to simulate an intelligent conversation with one or more humans. In this lab, we will establish the framework for our chatbot, which will be enhanced throughout the semester.
The ChatBot class will define a name field that identifies the chatbot (name your chatbot anything you like.) This will be an immutable field; Only an accessor method is required for the name field. The name field should be set in the default constructor.
The ChatBot class defines two additional methods, one returns an introductory message including the chatbot’s name. The other accepts a String and produces a String reply. At this point in time, the reply method always returns the same message.
This is what the UML diagram looks like
Chatbot (class or constructor)
minus (- private) name : String
plus (+ public) getName() : String
plus (+ public) introbot() : String
plus (+ public) public reply (userInput : String ) : String
ChatBot Client:
The client application will manage the chat between the end-used and the chatbot. The client is responsible for retrieving the end-user’s comment, passing it to the chatbot, and retrieving and displaying the chatbot’s response. The user’s or chatbot’s name should be used as the input prompt. Below is a sample run of the client:
Enter your name: Jeff
Hi! My name is mutebot
Jeff > hello
mutebot > I'm just learning to talk
THIS is my service class
/*
* Java Car service class
* @author blake
* 2/13/2012
*/
import
public class Chatbot
{
private String name;
private String introbot;
private String reply;
public Chatbot(String newName, String newIntrobot, String newReply)
{
name = newName;
}
public void setName (String n)
{
name = n;
}
public String getName()
{
return name;
}
THIS is my application class
import java.util.Scanner;
public class ChatbotClient
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("What is your name? ");
String name = input.nextLine();
System.out.println("\nHi " + name + " My name is copbot");
System.out.println(name);
String reply = input.nextLine();
System.out.println("/ncopbot" + "I'm just learning how to talk " );
}
}
I am not exactly sure if this is exactly what the problem asked or required for, or if this is the way to do it.
I think the service class might be okay, but I am not too sure about the application class as that is where you would do your accessors, and mutators and those sort of things, I guess you just set up your fields and instances in the service class.