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.

Do you have a question?

Do you have a question?

YES, and my question is

"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."

I am not sure if that is exactly the way I am suppose to do it or if it is correct or not. I think it is okay but not sure.

Who asked for this code to be written? Can you ask them what they want?

Who asked for this code to be written? Can you ask them what they want?

EDIT: I am editing the code to clarify it more.

I am the one that is actually creating the code, to look like what it asked for from the instructions.

/*
 * Java Car service class
 * @author blake
 * 2/13/2012
 */

public class Chatbot
{
   private final 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;
	}
}

HOPE that clarifies it a little bit.

Does it do what you want it to do when you execute it?
If not, explain the problem and tell us what you want it to do that is different.

Does it do what you want it to do when you execute it?
If not, explain the problem and tell us what you want it to do that is different.

It executes it, but not the way I want it.

I want it to show up more like the CHATBOT CLIENT example below (like the one above just reposting it that's all).

but not the way I want it.

How do you want it to execute?
Post some examples of how you want it.

How do you want it to execute?
Post some examples of how you want it.

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: Trish

Hi! My name is Mutebot

Trish > hello

mutebot > I'm just learning to talk

Like This :)

I want my code to show like that.

Where is the current output? I just saw it a minute ago and was going to compare the current output with the desired output and now the current output is gone????

Where is the current output? I just saw it a minute ago and was going to compare the current output with the desired output and now the current output is gone????

actually the one above is the desired output (the current output right now is in my second code.

The way it shows up right now is

What is your name?

Blake

Hi Blake, my name is copbot

Blake
Hello

\ncopbot I'm just learning how to talk

Enter your name: Trish <<< NO ? and on same line

Hi! My name is Mutebot <<< Here there is no name after Hi!

Trish > hello

mutebot > I'm just learning to talk <<<< Here the name is different and there is a >

What is your name? <<<< Here there is a ?

Blake <<< This was two lines later.

Hi Blake, my name is copbot <<<< Here there is a name after Hi and there is no !

Blake
Hello

\ncopbot I'm just learning how to talk <<<< Here there is a \n at the beginning ???

Use print vs println to keep the user's input on the same line.

Where did the \n in the output come from??? Is this output really from the program or are you making it up?
The code has:
System.out.println("/ncopbot" + "I'm just learning how to talk " );

If you can not correctly post the program's output, this is a great waste of time.

I'm done for the night. Good luck.

Use print vs println to keep the user's input on the same line.

Where did the \n in the output come from??? Is this output really from the program or are you making it up?
The code has:
System.out.println("/ncopbot" + "I'm just learning how to talk " );

If you can not correctly post the program's output, this is a great waste of time.

I'm done for the night. Good luck.

That is the actual code, that is how it came out, that is how it looked in the original application class, I posted it correctly, please look at the original code again.

Sorry this is different: \ vs /
\ncopbot
System.out.println("/ncopbot"

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: Trish

Hi! My name is Mutebot

Trish > hello

mutebot > I'm just learning to talk

Like This :)

I want my code to show like that.

What I've understood by this is that you want your chatbot to send messages triggered by certain phrases... such as "hi" or "hello" or something like that. Am I going right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.