Skip to content

Instantly share code, notes, and snippets.

@coffeejay
Created January 15, 2014 15:48
Show Gist options
  • Save coffeejay/8438613 to your computer and use it in GitHub Desktop.
Save coffeejay/8438613 to your computer and use it in GitHub Desktop.
/**
* A class representation of a BallotBox using an ArrayListBag.
*
* @author Jay Deuskar
*/
public class BallotBox{
private BagInterface<Ballot> ballots;
public BallotBox(){
ballots = new ArrayListBag<Ballot>();
}
public int getSize(){
return ballots.getCurrentSize();
}
public boolean isEmpty(){
return ballots.isEmpty();
}
public boolean add(Ballot ballot){
return ballots.add(ballot);
}
public Ballot remove (){
return ballots.remove();
}
public boolean remove(Ballot ballot){
return ballots.remove(ballot);
}
public void clear(){
ballots.clear();
}
public int getFrequencyOf(Ballot ballot){
return ballots.getFrequencyOf(ballot);
}
public boolean contains(Ballot ballot){
return ballots.contains(ballot);
}
public Object[] toArray(){
return (Object[])ballots.toArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment