码迷,mamicode.com
首页 > 其他好文 > 详细

枚举 用类的方法模拟枚举

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

标签:os   new   re   c   public   return   

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

枚举 用类的方法模拟枚举

标签:os   new   re   c   public   return   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!