blob: bf01f798c9ec2175fc1063d8dc8c99a31fba06bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package ca.mokhan.comp268;
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");
}
}
|