CS 4773 Object Oriented Systems, Spring 2005 Assignment 3

Due Wednesday, March 2, 2005


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.

The only message you can send to the server after the initial message containing your name has exactly three tokens. The first token is "vote" and the second one is the vote id. This is followed by the vote itself.
The last token will either be an integer (represented as printing characters) in the case of an integer vote, or one of the tokens "true" or "false". For example, if the vote id is "abc" and you want to send the integer value 923 as your vote, you would send "vote abc 923\n", for a total of 13 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:

  1. Set up your JBuilder project to use the server on gateway05 and port number 12345.
    To do this, go into Project -> Project Properties -> Run -> Edit
    and change the Application Parameters to
    gateway05 12345
  2. Use the turnin script that you used for assignment 1.
    Do the same thing as for assignment 1, except that since you are turning in assignment 3, execute:
         cs4773_turnin xxx.zip 3
  3. Hand in a hard copy of your java source code. I prefer that you print out your class files from JBuilder with syntax printing turned on.
    Use this cover sheet.
  4. As in assignment 1, send an email to the cs4773 account indicating whom you helped and who helped you on this assignment. Do not send this email to srobbins.

Please turn this in by the start of Friday's class.