-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarType.java
More file actions
50 lines (45 loc) · 1.07 KB
/
Copy pathCarType.java
File metadata and controls
50 lines (45 loc) · 1.07 KB
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
41
42
43
44
45
46
47
48
49
50
/**
* Different car types
* @author Benjamin Singleton
*/
public enum CarType {
ECONOMY("Economy"),
COMPACT("Compact"),
SEDAN("Sedan"),
LUXURY("Luxury"),
MINIVAN("Minivan"),
SUV("SUV");
private final String label;
private CarType(String label) {
this.label = label;
}
/**
* Get the CarType based on the label associated with it
* @param label the label of a CarType
* @return the CarType associated with the label
*/
public static CarType getCT(String label) {
switch (label) {
case "Economy":
return ECONOMY;
case "Compact":
return COMPACT;
case "Sedan":
return SEDAN;
case "Luxury":
return LUXURY;
case "Minivan":
return MINIVAN;
case "SUV":
return SUV;
}
return ECONOMY;
}
/**
* Get the label of the CarType
* @return the String representation of the CarType
*/
public String getLabel() {
return label;
}
}