diff --git a/projects/Magpiev2ActivityStarterCode/activity4/Magpie4b.java b/projects/Magpiev2ActivityStarterCode/activity4/Magpie4b.java index 42e216c..c568411 100644 --- a/projects/Magpiev2ActivityStarterCode/activity4/Magpie4b.java +++ b/projects/Magpiev2ActivityStarterCode/activity4/Magpie4b.java @@ -55,7 +55,18 @@ private String transformWouldYouLikeStatement(String statement) String restOfStatement = statement.substring(psn + 9).trim(); return "When would you like me to " + restOfStatement + " with you?"; } - + /** + * Take a statement with "I don't like ." and transform it into + * "You said 'I dislike '? What don't you like about it?" + * @param statement the user statement, assumed to contain "I don't like" + * @return the transformed statement + */ + private String transformIDontLikeStatement(String statement) + { + // Your code goes here + + return "You said 'I dislike " + statement.substring(12) + "'? What dont you like about it?"; // Modify this statement to return the correct String + } /** * Take a statement with "I want to ." and transform it into * "What would it mean to ?" @@ -160,7 +171,7 @@ public String getResponse(String statement) } else if (findKeyword(statement, "I want to", 0) >= 0) { response = transformIWantToStatement(statement); } else if (findKeyword(statement, "i dont like")>=0) { - response = "You said 'I dislike " + statement.substring(12) + "'? What dont you like about it?"; + response = transformIDontLikeStatement(statement); } else if (findKeyword(statement, "you dont like")>=0) { response = "You said I dislike " + statement.substring(12) + ". Why would you think that!"; } @@ -171,7 +182,7 @@ public String getResponse(String statement) if (statement.contains("dog")) { response = replaceWord(statement, "dog", "cat"); - } + } // return response; // Responses which require transformations