package com.heima.day1;
import java.util.Date;
public class EnumTextTwo {
/**
* @param args
*/
public static void main(String[] args) {
TrafficLampTwo tlw = TrafficLampTwo.GREEN;
System.out.println(tlw.nextLamp());
new Date(300) {
};
}
//
public enum TrafficLampTwo {
// public static final TrafficLampTwo RED = new TrafficLampTwo();
// public static final TrafficLampTwo YELLOW = new TrafficLampTwo();
// public static final TrafficLampTwo GREEN = new TrafficLampTwo();
// 定义 红 绿 黄 三栈灯
RED(30) {
@Override
public TrafficLampTwo nextLamp() {
// TODO Auto-generated method stub
return GREEN;
}
},
GREEN(45) {
@Override
public TrafficLampTwo nextLamp() {
// TODO Auto-generated method stub
return YELLOW;
}
},
YELLOW(5) {
@Override
public TrafficLampTwo nextLamp() {
// TODO Auto-generated method stub
return RED;
}
};
// 定义下一个灯是什么,由于是哪个灯很不确定
public abstract TrafficLampTwo nextLamp();
private int time; // 定义一个时间 用来红绿黄三盏灯的等待时间
private TrafficLampTwo(int time) {
this.time = time;
}
};
};
----------------------
new Date(300) {
}; 我就是不懂这句话的作用 ,还有和TrafficLampTwo有什么关系?
该贴已经同步到 袁野的微博 |