summaryrefslogtreecommitdiff
path: root/src/Q8/Communication.java
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
committermokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
commit7b4cb6a2eef3a0fcde7e998832427c73599e4a0a (patch)
tree75acc7cd8f3bd8a087e909db182c9e18a66879a1 /src/Q8/Communication.java
parent99a28d2dba93642e89a62ecf905a3bd4f138318d (diff)
use the exact naming convention for directories described by instructor
Diffstat (limited to 'src/Q8/Communication.java')
-rw-r--r--src/Q8/Communication.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Q8/Communication.java b/src/Q8/Communication.java
new file mode 100644
index 0000000..2e4c2a8
--- /dev/null
+++ b/src/Q8/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");
+ }
+}