Question: I recently got a challenging java homework. Could you help giving me examples and explanations? Thanks The requirement of the hw is below : Do

I recently got a challenging java homework. Could you help giving me examples and explanations? Thanks

The requirement of the hw is below :

Do a java class called Conversation

The Conversation class must define these object variables:

String tagWord; // substring to search for in a statement. 

//true if the statement response is constructed by extracting before tagWord,

// false is the response is constructed by extracting after.

boolean extractBefore; String responseBefore; //text to put before statement extract in the response String responseAfter; //text to put after statement extract in the response String default0Mod3; //Default response if wordCount(statement) = 0 % 3 String default1Mod3 //Default response if wordCount(statement) = 1 % 3 String default2Mod3 //Default response if wordCount(statement) = 2 % 3 

The Conversation class must define getter and setter methods for all the object variables, appropriate constructors, and these object methods:

//returns the word count of statement_, where a word is defined as any group

// of symbols, delimited by white space, containing at least one alphanumeric

// character. In this context, white space includes start and end of text,

// and/or one or more of these characters: ' ', \t, .

int wordCount(statement) { ...

//Returns a response to statement_. String response(String statement_) { ... //Transform statement_ by exchanging 1st & 2nd person pronouns // and possessives. Called from the response object method. String changePerson(String statement_) { ... //Returns an informative display of the state of all the object variables String toString() { ... 

My starting code:

public class Conversation { // substring to search for in a statement. // like "because", on the midterm programming String tagWord; //true if the statement response is constructed by extracting before tagWord, // false is the response is constructed by extracting after. boolean extractBefore; String responseBefore; //text to put before statement extract in the response String responseAfter; //text to put after statement extract in the response String default0Mod3; //Default response if wordCount(statement) = 0 % 3  String default1Mod3; //Default response if wordCount(statement) = 1 % 3 String default2Mod3; //Default response if wordCount(statement) = 2 % 3 //getter method for tagWord String getTagWord () { return this.tagWord; } //getTagWord String setTagWord(String tagWord) { String oldTagWord = this.tagWord; this.tagWord = tagWord; return oldTagWord; }//setTagWord() //returns the word count of statement_, where a word is defined as any group // of symbols, delimited by white space, containing at least one alphanumeric // character. In this context, white space includes start and end of text, // and/or one or more of these characters: ' ', \t, . int countWords(String statement_) { /* * [abc]+ == and it means one or more a, b, or c * (a|b) == a or b * are white space definition includes -- new line and * \t tab * String s = "This\tis \ta gap." * come up with a regular expression, using [], or perhaps |, * such that s.split() == 4 */ int = wordCount = statement_.split(/**/); return wordCount; } //Returns a response to statement_. String respond(String statement_) { } } //Conversation( 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!