public class TrafficLiight{
public static void main(String[] args){
TrafficLamp a=TrafficLamp.RED(30);
System.out.println(a.nextLamp());
}
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();
public static TrafficLamp RED(int i) {
// TODO Auto-generated method stub
return null;
}
private TrafficLamp(int time){
}
}
}
运行出错了 |
|