package test;
/*
* 3.根据交通信号灯颜色决定汽车停车、行驶和慢行
*/
public enum Light {
stop,run,slow
}
package test;
/*
* 根据交通信号灯颜色决定汽车停车、行驶和慢行
*/
public class CarDemo {
private Light light;
public static void main(String[] args) {
CarDemo red = new CarDemo();
red.light= Light.stop;
CarDemo yellow = new CarDemo();
yellow.light = Light.slow;
CarDemo green = new CarDemo();
green.light=Light.run;
System.out.println(red.light);
System.out.println(yellow.light);
System.out.println(green.light);
}
}