2015-09-07 11:44:36 -06:00
|
|
|
|
// enums/OzWitch.java
|
2015-11-14 16:18:05 -08:00
|
|
|
|
// <20>2016 MindView LLC: see Copyright.txt
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// The witches in the land of Oz.
|
|
|
|
|
|
|
|
|
|
public enum OzWitch {
|
|
|
|
|
// Instances must be defined first, before methods:
|
|
|
|
|
WEST("Miss Gulch, aka the Wicked Witch of the West"),
|
|
|
|
|
NORTH("Glinda, the Good Witch of the North"),
|
|
|
|
|
EAST("Wicked Witch of the East, wearer of the Ruby " +
|
|
|
|
|
"Slippers, crushed by Dorothy's house"),
|
|
|
|
|
SOUTH("Good by inference, but missing");
|
|
|
|
|
private String description;
|
|
|
|
|
// Constructor must be package or private access:
|
|
|
|
|
private OzWitch(String description) {
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
|
public String getDescription() { return description; }
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
for(OzWitch witch : OzWitch.values())
|
2015-11-03 12:00:44 -08:00
|
|
|
|
System.out.println(witch + ": " + witch.getDescription());
|
2015-06-15 17:47:35 -07:00
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
|
WEST: Miss Gulch, aka the Wicked Witch of the West
|
|
|
|
|
NORTH: Glinda, the Good Witch of the North
|
|
|
|
|
EAST: Wicked Witch of the East, wearer of the Ruby
|
|
|
|
|
Slippers, crushed by Dorothy's house
|
|
|
|
|
SOUTH: Good by inference, but missing
|
2015-09-07 11:44:36 -06:00
|
|
|
|
*/
|