首页 > 其他 > 详细

枚举 用类的方法模拟枚举

时间:2014-07-13 23:09:33      阅读:379      评论:0      收藏:0      [点我收藏+]

package cn.itcast.day1;

public class Weekday0 {
private Weekday0(){}
public static final Weekday0 SUN = new Weekday0();
public static final Weekday0 MON = new Weekday0();
public static final Weekday0 TUS = new Weekday0();
public static final Weekday0 WEN = new Weekday0();
public static final Weekday0 THU = new Weekday0();
public static final Weekday0 FRI = new Weekday0();
public static final Weekday0 SAT = new Weekday0();

public Weekday0 nextDay(){
if(this == SUN){
return MON;
}else if(this == MON){
return TUS;
}else if(this == TUS){
return WEN;
}else if(this == WEN){
return THU;
}else if(this == THU){
return FRI;
}else if(this == FRI){
return SAT;
}else{
return SUN;
}
}
public String toString(){
if(this == SUN){
return "SUN";
}else if(this == MON){
return "MON";
}else if(this == TUS){
return "TUS";
}else if(this == WEN){
return "WEN";
}else if(this == THU){
return "THU";
}else if(this == FRI){
return "FRI";
}else{
return "SAT";
}
}

}

枚举 用类的方法模拟枚举,布布扣,bubuko.com

枚举 用类的方法模拟枚举

原文:http://www.cnblogs.com/siashan/p/3840434.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!