candidate
Class Candidate

java.lang.Object
  extended by candidate.Candidate
All Implemented Interfaces:
java.lang.Comparable

public class Candidate
extends java.lang.Object
implements java.lang.Comparable


Constructor Summary
Candidate()
          Creates a default new instance of Candidate
Candidate(java.lang.String nm)
          creates a new instance of a candidate given a name.
 
Method Summary
 void addOneVote()
          add one vote to the candidate
 int compareTo(java.lang.Object obj)
          Compares two Candidates - based on number of votes received - needed for sorting - required since implements Comparable interface returns positive if passed object comparing to is less, zero if object comparing to is equal, negative if passed object comparing to is greater.
 boolean equals(java.lang.Object obj)
          determine if a passed Candidate has the same contents as the calling object (all contents).
 java.lang.String getName()
          report candidates name
 int getNumVotes()
          report candidate's number of votes
 boolean matches(Candidate toCompare)
          determine if a passed Candidate has the same name as the calling object (just name - could be used for finding the right candidate in a collection of candidates).
 boolean matches(java.lang.String toCompare)
          determine if a passed Sting is the same as the candidate name in the calling object (just name - could be used for finding the right candidate in a collection of candidates).
 void resetVotes()
          reset vote total to zero
 java.lang.String toString()
          produce a friendly string version of the object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Candidate

public Candidate()
Creates a default new instance of Candidate


Candidate

public Candidate(java.lang.String nm)
creates a new instance of a candidate given a name. Number of votes defaults to zero

Method Detail

getName

public java.lang.String getName()
report candidates name


getNumVotes

public int getNumVotes()
report candidate's number of votes


addOneVote

public void addOneVote()
add one vote to the candidate


resetVotes

public void resetVotes()
reset vote total to zero


equals

public boolean equals(java.lang.Object obj)
determine if a passed Candidate has the same contents as the calling object (all contents). Overrides version in java.lang.Object

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
produce a friendly string version of the object

Overrides:
toString in class java.lang.Object

matches

public boolean matches(Candidate toCompare)
determine if a passed Candidate has the same name as the calling object (just name - could be used for finding the right candidate in a collection of candidates).


matches

public boolean matches(java.lang.String toCompare)
determine if a passed Sting is the same as the candidate name in the calling object (just name - could be used for finding the right candidate in a collection of candidates).


compareTo

public int compareTo(java.lang.Object obj)
Compares two Candidates - based on number of votes received - needed for sorting - required since implements Comparable interface returns positive if passed object comparing to is less, zero if object comparing to is equal, negative if passed object comparing to is greater.

Specified by:
compareTo in interface java.lang.Comparable