Ignore:
Timestamp:
Oct 26, 2010, 6:37:15 AM (14 years ago)
Author:
Rick van der Zwet
Message:

Some more test cases and a working program. Let's go to the University.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • liacs/TOOS/assignment1/src/Census.java

    r209 r210  
    2222   * @return boolean with conjuction of voters or null on error.
    2323   */
    24   public static Boolean census(HashSet<Voter> voters) {
     24  public Boolean census(HashSet<Voter> voters) {
     25    logger.debug("Starting new comparison");
    2526
    2627    /* Nobody likes voting on Tuesday don't they? */
    2728    Calendar rightNow = Calendar.getInstance();
    2829    if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
     30      logger.debug("Sorry not today");
    2931      return false;
     32    }
     33
     34    /* No voters return error as result cannot be conclusive */
     35    if (voters == null) {
     36      return null;
    3037    }
    3138
    3239    /* Check all votes to make it a fair voting system */
    3340    for (Voter v: voters) {
    34       logger.debug(v.getVote());
    3541      /* Some vote is not set correctly or of wrong return value */
    36       if (v.getVote() == null || (!(v.getVote() instanceof Boolean))) {
    37         logger.debug("Invalid type");
     42      if (v == null || v.getVote() == null || (!(v.getVote() instanceof Boolean))) {
    3843        return null;
    3944      }
    4045
     46      logger.debug(v.getVote());
    4147      /* All has to be in agreement */
    4248      if (v.getVote() == false) {
Note: See TracChangeset for help on using the changeset viewer.