您的位置:首页 > 编程语言 > Java开发

java中枚举在游戏开发中作用

2017-06-28 14:06 127 查看


package com.hai.tao;

public enum Color {

REDD("红色", 11), GREENN("绿色", 22), BLUEE("白色", 33), YELLOO("黄色", 44);

private String name;

private int index;

private Color(String name, int index) {

this.name = name;

this.index = index;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getIndex() {

return index;

}

public void setIndex(int index) {

this.index = index;

}
}


package com.hai.tao;

public class test {

/**
* @param args
*/
public static void main(String[] args) {
// 遍历所有的枚举

for (Color color : Color.values()) {

System.out.println(color + "       " + color.getName() + "      " + color.getIndex());
}
}

}




java中的枚举在多人在线游戏后台开发中扮演什么角色昵?

回答是,通常用于消息处理器类的注册



FR:徐海涛(Hunk Xu)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: