public enum TrafficLamp{
RED(30){
public TrafficLamp nextLamp(){
return GREEN;
}
},
GREEN(45){
public TrafficLamp nextLamp(){
return YELLOW;
}
},
YELLOW(5){
public TrafficLamp nextLamp(){
return RED;
}
};
public abstract TrafficLamp nextLamp();
private int time;
private TrafficLamp(int time){this.time = time;}
}
怎么让这段程序运行起来,直接调用吗,为什么我只初始从红灯开始,运行不起来呢,只调用了一次下一个灯的方法, 请帮忙写出代码,谢谢
|