Index: liacs/TOOS2010/assignment2/build.xml
===================================================================
--- liacs/TOOS2010/assignment2/build.xml	(revision 231)
+++ liacs/TOOS2010/assignment2/build.xml	(revision 231)
@@ -0,0 +1,80 @@
+<project name="Census" >
+
+  <property name="src.dir" value="src"/>
+  <property name="lib.dir" value="lib" />
+  <property name="build.dir" value="build"/>
+  <property name="classes.dir" value="${build.dir}/classes"/>
+  <property name="jar.dir" value="${build.dir}/jar"/>
+  <property name="report.dir"  value="${build.dir}/junitreport"/>
+
+  <property name="javac.includeAntRuntime" value="false" />
+  <property name="main-class" value="nl.rickvanderzwet.toos.assignment1.Census" />
+
+
+  <path id="classpath">
+    <fileset dir="${lib.dir}" includes="**/*.jar"/>
+  </path>
+  <path id="application" location="${jar.dir}/${ant.project.name}.jar" />
+
+
+  <target name="clean">
+      <delete dir="${build.dir}"/>
+  </target>
+
+  <target name="compile">
+      <mkdir dir="${classes.dir}"/>
+      <javac srcdir="${src.dir}" destdir="${classes.dir}" 
+        includeAntRuntime="${javac.includeAntRuntime}" 
+        classpathref="classpath"
+        debug="true">
+        <compilerarg value="-Xlint:unchecked" />
+      </javac>
+      <copy todir="${classes.dir}">
+          <fileset dir="${src.dir}" excludes="**/*.java"/>
+      </copy>
+  </target>
+
+  <target name="jar" depends="compile">
+      <mkdir dir="${jar.dir}"/>
+      <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
+          <manifest>
+              <attribute name="Main-Class" value="${main-class}" />
+          </manifest>
+      </jar>
+  </target>
+
+  <target name="run" depends="clean, jar">
+      <java fork="true" classname="${main-class}">
+        <classpath>
+          <path refid="classpath" />
+          <path refid="application"/>
+        </classpath>
+      </java>
+  </target>
+
+  <target name="junit" depends="clean, jar">
+    <mkdir dir="${report.dir}" />
+    <junit printsummary="no">
+      <classpath>
+        <path refid="classpath"/>
+        <path refid="application"/>
+      </classpath>
+      
+      <formatter type="xml" />
+      <formatter type="brief" usefile="false" />
+
+      <batchtest fork="yes" todir="${report.dir}">
+        <fileset dir="${src.dir}" includes="*Test.java"/>
+      </batchtest>
+    </junit>
+  </target>
+
+  <target name="junitreport">
+    <junitreport todir="${report.dir}">
+      <fileset dir="${report.dir}" includes="TEST-*.xml"/>
+      <report todir="${report.dir}"/>
+    </junitreport>
+  </target>
+
+
+</project>
Index: liacs/TOOS2010/assignment2/src/Census.java
===================================================================
--- liacs/TOOS2010/assignment2/src/Census.java	(revision 231)
+++ liacs/TOOS2010/assignment2/src/Census.java	(revision 231)
@@ -0,0 +1,56 @@
+package nl.rickvanderzwet.toos.assignment1;
+
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Enumeration;
+
+import nl.rickvanderzwet.toos.assignment1.Voter;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Logger;
+
+public class Census {
+  static Logger logger = Logger.getLogger(Census.class);
+  public static void main(String[] args) {
+  }
+  /**
+   * Calculates the end-vote for a list of voters, given a certain set of creteria's:
+   *   - No voter is allowed more than one time on the list.
+   *   - All voters present needed to have a vote set.
+   *   - Voter.getVote() : Boolean
+   * 
+   * @return boolean with conjuction of voters or null on error.
+   */
+  public Boolean census(HashSet<Voter> voters) {
+    logger.debug("Starting new comparison");
+
+    /* Nobody likes voting on Tuesday don't they? */
+    Calendar rightNow = Calendar.getInstance();
+    if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
+      logger.debug("Sorry not today");
+      return false;
+    }
+
+    /* No voters return error as result cannot be conclusive */
+    if (voters == null) {
+      return null;
+    }
+
+    /* Check all votes to make it a fair voting system */
+    for (Voter v: voters) {
+      /* Some vote is not set correctly or of wrong return value */
+      if (v == null || v.getVote() == null || (!(v.getVote() instanceof Boolean))) { 
+        return null;
+      }
+
+      logger.debug(v.getVote());
+      /* All has to be in agreement */
+      if (v.getVote() == false) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+}
+
Index: liacs/TOOS2010/assignment2/src/CensusTest.java
===================================================================
--- liacs/TOOS2010/assignment2/src/CensusTest.java	(revision 231)
+++ liacs/TOOS2010/assignment2/src/CensusTest.java	(revision 231)
@@ -0,0 +1,66 @@
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Enumeration;
+
+import nl.rickvanderzwet.toos.assignment1.Voter;
+import nl.rickvanderzwet.toos.assignment1.Census;
+
+public class CensusTest extends junit.framework.TestCase {
+
+    public void testEmptyVoteList() {
+      HashSet<Voter> v = null;
+      Census c = new Census();
+      assertNull(c.census(v));    
+    }
+
+    public void testAllPositiveVote() {
+      HashSet<Voter> v = new HashSet<Voter>();
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+
+      Census c = new Census();
+      assertTrue(c.census(v));    
+    }
+
+    public void testNegativeVote() {
+      HashSet<Voter> v = new HashSet<Voter>();
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+      v.add(new Voter(false));
+      v.add(new Voter(true));
+
+      Census c = new Census();
+      assertFalse(c.census(v));    
+    }
+
+    public void testInvalidVoter() {
+      HashSet<Voter> v = new HashSet<Voter>();
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+      v.add(new Voter(false));
+      v.add(null);
+
+      Census c = new Census();
+      assertNull(c.census(v));    
+    }
+
+    public void testDuplicateVote() {
+      HashSet<Voter> v = new HashSet<Voter>();
+      Voter d = new Voter(true);
+      assertTrue(v.add(d));
+      assertFalse(v.add(d));
+    }
+
+    public void testUnusedVote() {
+      HashSet<Voter> v = new HashSet<Voter>();
+      v.add(new Voter(true));
+      v.add(new Voter(true));
+      v.add(new Voter(false));
+      v.add(new Voter());
+
+      Census c = new Census();
+      assertNull(c.census(v));    
+    }
+}
Index: liacs/TOOS2010/assignment2/src/Voter.java
===================================================================
--- liacs/TOOS2010/assignment2/src/Voter.java	(revision 231)
+++ liacs/TOOS2010/assignment2/src/Voter.java	(revision 231)
@@ -0,0 +1,15 @@
+package nl.rickvanderzwet.toos.assignment1;
+
+public class Voter {
+  public Voter() {
+    fvote = null;
+  }
+  public Voter(Boolean vote) {
+    fvote = vote;
+  }
+
+  public Boolean getVote() { 
+    return fvote;
+  }
+  public Boolean fvote; 
+}
Index: liacs/TOOS2010/assignment2/src/VoterTest.java
===================================================================
--- liacs/TOOS2010/assignment2/src/VoterTest.java	(revision 231)
+++ liacs/TOOS2010/assignment2/src/VoterTest.java	(revision 231)
@@ -0,0 +1,30 @@
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Enumeration;
+
+import nl.rickvanderzwet.toos.assignment1.Voter;
+
+/** 
+ * Make sure both the variable and the function return the proper values if set.
+ */
+public class VoterTest extends junit.framework.TestCase {
+
+
+    public void testTrueVote() {
+      Voter v = new Voter(true);
+      assertTrue(v.fvote);
+      assertTrue(v.getVote());
+    }
+
+    public void testFalseVote() {
+      Voter v = new Voter(false);
+      assertFalse(v.fvote);
+      assertFalse(v.getVote());
+    }
+
+    public void testEmptyVote() {
+      Voter v = new Voter();
+      assertNull(v.fvote);
+      assertNull(v.getVote());
+    }
+}
Index: liacs/TOOS2010/assignment2/src/log4j.properties
===================================================================
--- liacs/TOOS2010/assignment2/src/log4j.properties	(revision 231)
+++ liacs/TOOS2010/assignment2/src/log4j.properties	(revision 231)
@@ -0,0 +1,6 @@
+log4j.rootLogger=DEBUG,stdout
+#
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%r [%t] %p %C  - %m%n
