Enum示例

package SecondTermUp;

public enum WorkersInformation {
	Eid1,Eid2,Whereid,Ename,Emoblie,Etype1,Etype2,age;

}




package SecondTermUp;

import java.util.*;

public class SecondHomework {
	public static void GetInformation(WorkersInformation chaxun) {
		switch(chaxun) {
        case Eid1:
            System.out.println("车间号为WS1的员工工号有:W1,W2,W3,W4,W5,W6,W7");
        break;
        case Whereid:
            System.out.println("车间号为WS2的员工工号有:W8,W9,W10,W11,W12,W13,W14");
        break;
        case Etype1:
            System.out.println("工种为special的员工工号有:W1,W8");
            break;
        case Etype2:
            System.out.println("工种为expert的员工工号有:W2,W9");
            break;
        case Eid2:
            System.out.println("工种为common的员工工号有:W3,W4,W5,W6,W7,W10,W11,W12,W13,W14");
            break;
        }
    }
    

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
    	GetInformation(WorkersInformation.Eid1);
    	GetInformation(WorkersInformation.Whereid);
    	GetInformation(WorkersInformation.Etype1);
    	GetInformation(WorkersInformation.Etype2);
    	GetInformation(WorkersInformation.Eid2);
        System.out.println("工龄为"+WorkersInformation.Eid1.ordinal()+"年的员工工号为W4,W5,W6,W7,W11,W12,W13,W14");
        System.out.println("工龄为"+WorkersInformation.Etype2.ordinal()+"年的员工工号为W2,W9");
        System.out.println("工龄为"+WorkersInformation.age.ordinal()+"年的员工工号为W1,W8");
    }
}

Enum示例

 代码还可以改进......

上一篇:C++ 第八章 结构、联合与枚举 - 8.1 引言


下一篇:枚举enum