Class Client

java.lang.Object
  |
  +--Client

public class Client
extends java.lang.Object

The underlying code for the election client: this is where all the work gets done. User actions through the user interface get resolved into calls to this class, and it calls user interface (ClientDisplay) methods to display results. The client communicates with the server over a single connection.


Method Summary
 void connect()
          Make a connection to the server.
 void displayCandidates(java.lang.String election, ClientDisplay display)
          Obtain the list of candidates for the specified election and show them on the specified display.
 void vote(java.lang.String election, java.lang.String candidate, ClientDisplay display)
          Cast the vote for the candidate in the specified election and display the results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

displayCandidates

public void displayCandidates(java.lang.String election,
                              ClientDisplay display)
                       throws MalformedMessageException,
                              DisplayException,
                              java.io.IOException
Obtain the list of candidates for the specified election and show them on the specified display. Various errors could result: the reply could be mangled (not of the Message class), the election could be closed or invalid, or the reply could be of the wrong message type, or there might be an I/O error.

MalformedMessageException
DisplayException
java.io.IOException

vote

public void vote(java.lang.String election,
                 java.lang.String candidate,
                 ClientDisplay display)
          throws MalformedMessageException,
                 DisplayException,
                 java.io.IOException
Cast the vote for the candidate in the specified election and display the results. Errors could arise because the election or candidate are not valid, the election is closed, or the reply is of the wrong class or type.

MalformedMessageException
DisplayException
java.io.IOException

connect

public void connect()
             throws java.net.UnknownHostException,
                    ServerUnreachableException,
                    java.io.IOException
Make a connection to the server. May throw an exception if the server is unreachable.

java.net.UnknownHostException
ServerUnreachableException
java.io.IOException