May 21, 2003
The code in this lab shows you several ways in which you can carry on
a dialog with another user. All examples first use the ConsoleRange
iterator to track the interactions with a local user. Your task is to modify
these examples, so that the programs will carry out the same dialog, but
this time with another user connected to your computer via Internet connection.
The first two methods in the TestSuite class TestSocketEchoServer and TestSocketEchoClient allow you to become either a client or a server for an internet connection. Run the program, connect to a friend's computer, and carry out the exchange of messages. Try to be both a server at one time and a client at another time.
The next part modifies the original code to use the SocketIterator. Again, there are two ways of using the SocketIterator - either you are a server, or you are a client. Again, verify that you can make the connection in both directions.
The method TestInConsoleRangeEcho implements the same interactions
with the local user, as you have done in Part 1. Make sure it works correctly.
Use it as a model for further interactions.
Now run the TestInConsoleRangeReply method. Here we are seeing two-way user interactions. Implement a method TestSocketRangeReply, which uses SocketRange in both ways.
The method TestInConsoleRangeIntegers illustrates how to convert
the digits from a String to a numerical value - in our case to integers.
Again, implement similar method to send numbers over the network.
Enjoy the fruits of your labor by replacing the sending of some boring numbers with playing a simple guessing game with your friend. Use the code in TestNumberGame as a model.
This may be a bit too much, so, you may need some help. No problem, as
our Eliza program is ready to step in. The Eliza class
contains a collection of possible answers to some serious questions you need
to have answered. You may add to the collection of answers. But, most importantly,
modify the code, so that your program can offer advice to your distant friend
- and so that your friend can offer similar advice to you.
Have fun.