summaryrefslogtreecommitdiff
path: root/src/main/java/ca/mokhan/assignment1/Communication.java
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-05 19:25:48 -0600
committermokha <mokha@cisco.com>2019-05-05 19:25:48 -0600
commit46e409f3ca33ec3c7546d0589301c2a4f967c10a (patch)
tree55ed5a3297517719af1856f8fd0fa848dd4b94b5 /src/main/java/ca/mokhan/assignment1/Communication.java
parentc66b9591c81f93e3966050cc7c88981018e9b542 (diff)
collapse assignment1 dir
Diffstat (limited to 'src/main/java/ca/mokhan/assignment1/Communication.java')
-rw-r--r--src/main/java/ca/mokhan/assignment1/Communication.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/ca/mokhan/assignment1/Communication.java b/src/main/java/ca/mokhan/assignment1/Communication.java
new file mode 100644
index 0000000..2e4c2a8
--- /dev/null
+++ b/src/main/java/ca/mokhan/assignment1/Communication.java
@@ -0,0 +1,40 @@
+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 boolean isAtLeast(Communication other) {
+ return this.compareTo(other) >= 0;
+ }
+
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ 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);
+
+ public static Communication findBy(String name) {
+ switch (name) {
+ case "poor":
+ return Communication.Poor;
+ case "average":
+ return Communication.Average;
+ case "excellent":
+ return Communication.Excellent;
+ }
+ throw new IllegalArgumentException("Unknown communication type");
+ }
+}