For this assignment you will design the client part of a student voting system. Each student will run the client application on his/her computer. The client will connect to the server running on mine. The server will periodically ask for a vote on a given topic. Clients will then vote and the server will tally the results.
The client application will take a command line that start with the host name of the server and the port number to use for communication. The rest of the command line will contain the student's name.
Communication between the client and the server will be byte-oriented. Each message sent will consists of a sequence of bytes terminated by a newline byte.
After making the connection, the client will send a message containing only the student's name (gotten from the command line) and of course the terminating newline.
The following are the valid messages that can be sent from the server. Each message starts with a token indicating the type of message followed by a token which is the vote id. The vote id is use to distinguish between different vote. Tokens consist of printing characters separated by blanks. The rest of the line contains additional information. Note that in the following, the messages are written as if they are strings, but in fact they will be sent as a sequence of bytes.
Remember that all communication is done using bytes, not Java characters or Java strings. You will want to write a method to read a line and return a String and one that has a String parameter and sends the corresponding line. You cannot use either readLine or getChars from the Java I/O library as these assume that unicode characters are transmitted.
For this part of the assignment you will write the client code. It should have an nice user interface. It is up to you to make this user-friendly.
In doing your design, you should separate the user interface from the rest of the program. Essentially there are three parts to this assignment: The user interface, the string manipulation, and the I/O.
Do not wait until the last minute to start this assignment. In the near future, (before the due date) you will be given an assignment to write the server. The server is considerably more complicated. You must figure out how you are going to test your client before having the server completed. Testing of your program is an important part of this project. If you have a bidirectional UICI server from OS, you can use that to test your client, since all communication is done with printing characters (and the newline).
Please keep in mind that I will be out of town February 23-27.
Turning in your assignment:
There are four parts to turning in this assignment:
Please turn this in by the start of Friday's class.