我不是什么“//扫描仪等”没有,但方法返回类型应该是decizion:
public static decizion yourDecizion() { ... }
此外,您可以将Y,N等值添加到枚举常量:
public enum decizion{
YES("Y"), NO("N"), OTHER;
String key;
decizion(String key) { this.key = key; }
//default constructor, used only for the OTHER case,
//because OTHER doesn't need a key to be associated with.
decizion() { }
decizion getValue(String x) {
if ("Y".equals(x)) { return YES; }
else if ("N".equals(x)) { return NO; }
else if (x == null) { return OTHER; }
else throw new IllegalArgumentException();
}
}
然后,在该方法中,您可以这样做:
public static decizion yourDecizion() {
...
String key = ...
return decizion.getValue(key);
}