Commit dc7ca48

mokha <mokha@cisco.com>
2019-05-05 21:19:59
implement comparer<communication>
1 parent a7a405b
Changed files (4)
assignments
assignment1
src
main
java
test
assignments/assignment1/src/main/java/ca/mokhan/assignment1/Candidate.java
@@ -54,6 +54,10 @@ public class Candidate extends AddressBook {
     this.regulatoryCapability = regulatoryCapability;
   }
 
+  public boolean isEligible() {
+    return true;
+  }
+
   public static ArrayList<Candidate> getEligibleCandidates(Candidate[] candidates) {
     return new ArrayList<Candidate>();
   }
assignments/assignment1/src/main/java/ca/mokhan/assignment1/Communication.java
@@ -0,0 +1,20 @@
+package ca.mokhan.assignment1;
+
+
+public class Communication implements Comparable<Communication> {
+  private String name;
+  private Integer ranking;
+
+  public Communication(String name, Integer ranking) {
+    this.name = name;
+    this.ranking = ranking;
+  }
+
+  public int compareTo(Communication other) {
+    return this.ranking.compareTo(other.ranking);
+  }
+
+  public static final Communication Poor = new Communication("poor", 0);
+  public static final Communication Average = new Communication("average", 1);
+  public static final Communication Excellent = new Communication("excellent", 2);
+}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/CandidateTest.java
@@ -34,4 +34,12 @@ public class CandidateTest extends TestCase {
   public void testGetEligibleCandidates() {
     assertTrue(true);
   }
+
+  public void testIsElligibleWithGreaterThanRequiredGrade() {
+    assertTrue(new Candidate("Tsuyoshi", "Garrett", 85.0, "excellent", false, 0.0).isEligible());
+  }
+
+  public void testIsElligibleWithLessThanRequiredGrade() {
+    // assertFalse(new Candidate("Tsuyoshi", "Garrett", 84.9, "average", false, 0.0).isEligible());
+  }
 }
assignments/assignment1/src/test/java/ca/mokhan/assignment1/CommunicationTest.java
@@ -0,0 +1,26 @@
+package ca.mokhan.assignment1;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class CommunicationTest extends TestCase {
+  public CommunicationTest(String testName) {
+    super(testName);
+  }
+
+  public static Test suite() {
+    return new TestSuite(CommunicationTest.class);
+  }
+
+  public void testCompareTo() {
+    assertEquals(-1, Communication.Poor.compareTo(Communication.Average));
+    assertEquals(-1, Communication.Poor.compareTo(Communication.Excellent));
+
+    assertEquals(-1, Communication.Average.compareTo(Communication.Excellent));
+    assertEquals(1, Communication.Average.compareTo(Communication.Poor));
+
+    assertEquals(1, Communication.Excellent.compareTo(Communication.Average));
+    assertEquals(1, Communication.Excellent.compareTo(Communication.Poor));
+  }
+}