From 3c2be35d16d7482442911f5b06b68512f86e15b5 Mon Sep 17 00:00:00 2001 From: mokha Date: Sun, 5 May 2019 19:36:09 -0600 Subject: butcher default directory structure to make instructor happy --- src/Communication.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Communication.java (limited to 'src/Communication.java') diff --git a/src/Communication.java b/src/Communication.java new file mode 100644 index 0000000..2e4c2a8 --- /dev/null +++ b/src/Communication.java @@ -0,0 +1,40 @@ +package ca.mokhan.assignment1; + +public class Communication implements Comparable { + 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"); + } +} -- cgit v1.2.3