创建枚举:
package 姜;
public enum wk {
WS1,WS2,special,expert,common,nb
}
使用枚举:
package 姜;
public class fz {
public static void doit(XINXI a) {
switch(a) {
case WS1:
System.out.println("车间号为WS1的员工工号有:W1,W2,W3,W4,W5,W6,W7");
break;
case WS2:
System.out.println("车间号为WS2的员工工号有:W8,W9,W10,W11,W12,W13,W14");
break;
case special:
System.out.println("工种为special的员工工号有:W1,W8");
break;
case expert:
System.out.println("工种为expert的员工工号有:W2,W9");
break;
case common:
System.out.println("工种为common的员工工号有:W3,W4,W5,W6,W7,W10,W11,W12,W13,W14");
break;
}
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
doit(XINXI.WS1);
doit(XINXI.WS2);
doit(XINXI.special);
doit(XINXI.expert);
doit(XINXI.common);
System.out.println("工龄为"+XINXI.WS1.ordinal()+"年的员工工号为W4,W5,W6,W7,W11,W12,W13,W14");
System.out.println("工龄为"+XINXI.expert.ordinal()+"年的员工工号为W2,W9");
System.out.println("工龄为"+XINXI.nb.ordinal()+"年的员工工号为W1,W8");
}
}