代码是
- 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();
- }
复制代码 |