edu.rit.survey
Class SurveyVote

java.lang.Object
  extended by edu.rit.survey.SurveyVote

public class SurveyVote
extends Object

Class SurveyVote encapsulates the user's vote in a survey.

The survey vote object keeps track of one participant's vote. A timestamp (logical clock value) is associated with the vote as well. Each time the participant changes the vote, the timestamp is incremented. The timestamp is limited to a maximum of 32767.


Constructor Summary
SurveyVote()
          Construct a new survey vote object.
 
Method Summary
 boolean isVoteFor(int i)
          Determine if there is a vote for the given answer.
 void read(ObjectInput in)
          Read this survey vote from the given object input stream.
 void setVoteFor(int i)
          Record a vote for the given answer.
 void write(ObjectOutput out)
          Write this survey vote to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SurveyVote

public SurveyVote()
Construct a new survey vote object. Initially, the participant has not voted yet.

Method Detail

isVoteFor

public boolean isVoteFor(int i)
Determine if there is a vote for the given answer.

Parameters:
i - Answer index (0-3).
Returns:
True if there is a vote for answer i, false otherwise.

setVoteFor

public void setVoteFor(int i)
Record a vote for the given answer. The timestamp is incremented.

Parameters:
i - Answer index (0-3).
Throws:
IllegalStateException - (unchecked exception) Thrown if the timestamp is at the maximum (32767).

write

public void write(ObjectOutput out)
           throws IOException
Write this survey vote to the given object output stream.

Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

read

public void read(ObjectInput in)
          throws IOException
Read this survey vote from the given object input stream.

Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.