Changeset 210 for liacs/TOOS/assignment1/src/Census.java
- Timestamp:
- Oct 26, 2010, 6:37:15 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
liacs/TOOS/assignment1/src/Census.java
r209 r210 22 22 * @return boolean with conjuction of voters or null on error. 23 23 */ 24 public static Boolean census(HashSet<Voter> voters) { 24 public Boolean census(HashSet<Voter> voters) { 25 logger.debug("Starting new comparison"); 25 26 26 27 /* Nobody likes voting on Tuesday don't they? */ 27 28 Calendar rightNow = Calendar.getInstance(); 28 29 if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) { 30 logger.debug("Sorry not today"); 29 31 return false; 32 } 33 34 /* No voters return error as result cannot be conclusive */ 35 if (voters == null) { 36 return null; 30 37 } 31 38 32 39 /* Check all votes to make it a fair voting system */ 33 40 for (Voter v: voters) { 34 logger.debug(v.getVote());35 41 /* 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))) { 38 43 return null; 39 44 } 40 45 46 logger.debug(v.getVote()); 41 47 /* All has to be in agreement */ 42 48 if (v.getVote() == false) {
Note:
See TracChangeset
for help on using the changeset viewer.