在Think in java中的基础上做了一些调整
package enumerated;
//: enumerated/OzWitch.java
// The witches in the land of Oz.
import static net.mindview.util.Print.*;
public enum OzWitch {
// Instances must be defined first, before methods:
WEST("西"), NORTH("北"), EAST("东"), SOUTH("南");
private String description;
private OzWitch(String description) {
this.setDescription(description);
}
/**
* @param description the description to set
*/
private void setDescription(String description) {
this.description = description;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
public static void main(String[] args) {
for(OzWitch o : OzWitch.values()){
print(o + ":" + o.getDescription());
}
}
}