Click to See Complete Forum and Search --> : program help


sweetgal
10-22-2006, 09:30 PM
hi everyone,
i am writing a program for class.. but it requires a class to be written. The program is going to act as a simple pyschotherapist and i am having such a hard time figuring out the class.
I have to store each set of keywords and matching responses into a Dialog object, where the dialog is the following class:

class Dialog {
private String[] keywords;
private String[] responses;
private int keywordCount = 0;
private int responseCount = 0;

public Dialog(int numKeywords, int numResponses) {
String[] keywords = new keywords[numKeywords];
String[] responses = new responses[numResponses];
}

//Adds the specified keyword
public void addKeyword(String keywords) {
keywordCount++;
}

//Ads the specified response
public void addResponse(String[] responses) {
responseCount++;
}

//Searches input for a matching keyword. If one is found,
//returns a randomly chosen response. If no keyword is found,
//returns null.
public String getResponse(String input) {
String chosenResponse = null;
int i, j;
if (


this is all i have so far..and the main method will create an array named dialogs containing 13 dialog objects.Each object will be individually created and stored into the arrary. For example, the following statements create a Dialog object and store it into position 0 of the array:
dialogs[0] = new Dialog(1, );
dialogs[0].addKeyword("always");
dialogs[0].addResponse("Can you think of a specific example?");

The after reading the user's input, the main method will cal the getResponse method once for each object in the array. When getResponse returns a non-null response, main will print this response and break out of the loop.

i need help finishing the class..

agent_x91
10-30-2006, 04:25 AM
If you refer to your other thread, I posted a reply there to help you.