Changeset 209 for liacs/TOOS
- Timestamp:
- Oct 26, 2010, 6:19:27 AM (14 years ago)
- Location:
- liacs/TOOS/assignment1
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
liacs/TOOS/assignment1/build.xml
r208 r209 25 25 <mkdir dir="${classes.dir}"/> 26 26 <javac srcdir="${src.dir}" destdir="${classes.dir}" 27 includeAntRuntime="${javac.includeAntRuntime}" classpathref="classpath"> 28 27 includeAntRuntime="${javac.includeAntRuntime}" 28 classpathref="classpath" 29 debug="true"> 29 30 <compilerarg value="-Xlint:unchecked" /> 30 31 </javac> … … 52 53 </target> 53 54 54 <target name="junit" depends=" jar">55 <target name="junit" depends="clean, jar"> 55 56 <mkdir dir="${report.dir}" /> 56 57 <junit printsummary="no"> -
liacs/TOOS/assignment1/src/Census.java
r206 r209 13 13 static Logger logger = Logger.getLogger(Census.class); 14 14 public static void main(String[] args) { 15 BasicConfigurator.configure();16 17 Census census = new Census();18 19 HashSet<Voter> voters = new HashSet<Voter>();20 voters.add(new Voter(true));21 voters.add(new Voter(true));22 Voter duplicate = new Voter(true);23 voters.add(duplicate);24 voters.add(duplicate);25 //voters.add(new Voter());26 27 logger.info(census.census(voters));28 15 } 29 16 /** … … 35 22 * @return boolean with conjuction of voters or null on error. 36 23 */ 37 public Boolean census(HashSet<Voter> voters) { 24 public static Boolean census(HashSet<Voter> voters) { 25 38 26 /* Nobody likes voting on Tuesday don't they? */ 39 27 Calendar rightNow = Calendar.getInstance(); 40 if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar. TUESDAY) {28 if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) { 41 29 return false; 42 30 } … … 47 35 /* Some vote is not set correctly or of wrong return value */ 48 36 if (v.getVote() == null || (!(v.getVote() instanceof Boolean))) { 49 return false; 37 logger.debug("Invalid type"); 38 return null; 50 39 } 51 40 -
liacs/TOOS/assignment1/src/CensusTest.java
r208 r209 1 package nl.rickvanderzwet.toos.assignment1;2 3 1 import java.util.Calendar; 4 2 import java.util.HashSet; … … 11 9 12 10 public void testEmptyVoteList() { 11 HashSet<Voter> v = null; 13 12 Census c = new Census(); 14 assertTrue(c.census( null).equals(null));13 assertTrue(c.census(v).equals(null)); 15 14 } 16 17 public void testNoVote() { 18 fail("An error message"); 15 16 public void testAllPositiveVote() { 17 HashSet<Voter> v = new HashSet<Voter>(); 18 v.add(new Voter(true)); 19 v.add(new Voter(true)); 20 v.add(new Voter(true)); 21 v.add(new Voter(true)); 22 23 Census c = new Census(); 24 assertTrue(c.census(v)); 19 25 } 20 26 27 public void testNegativeVote() { 28 HashSet<Voter> v = new HashSet<Voter>(); 29 v.add(new Voter(true)); 30 v.add(new Voter(true)); 31 v.add(new Voter(false)); 32 v.add(new Voter(true)); 33 34 Census c = new Census(); 35 assertFalse(c.census(v)); 36 } 21 37 }
Note:
See TracChangeset
for help on using the changeset viewer.