In this version of Eliza, we'll implement an actual pattern. We'll start by selecting
an easy one - the "BECAUSE" pattern - that works like this:
string input = <something the user said> Pattern p = new Pattern("BECAUSE"); if (p.MatchesInput(input)) { Console.Writeline (p.GenerateResponse()); }Our job is to write the code for: MatchesInput() GenerateResponse()We'll get to this in a minute. First, let's simplify Eliza a bit. Simplifying ElizaBecause we've introduced the Pattern class, we can simply the Eliza's logic a bit.
Implementing the BECAUSE patternOur job is to write the code for these methods in the Pattern class:MatchesInput() GenerateResponse() TestingTesting is a crucial part of software development. Before you can say you're done, you should test your code with different inputs to verify all parts of it work correctly. Run the driver program and verify that it behaves as expected, by giving it this test input and comparing the results with your app.WELCOME! PLEASE TELL ME YOUR PROBLEM. > I love pizza. PLEASE GO ON. > I also love burgers. PLEASE GO ON. > I think I'm fat because I eat too much. WHAT OTHER REASONS MIGHT THERE BE? > There's really not much more to say. PLEASE GO ON. > Nah - I'm done talking with you. PLEASE GO ON. > Bye. GOODBYE! IT WAS NICE TALKING WITH YOU. COMPARE YOUR Pattern.cs and Eliza.cs WITH THE FILES IN THE SOLUTION. |