public class lampController {
private Lamp currentLamp;
public lampController() {
this.currentLamp = Lamp.S2N;
this.currentLamp.light();
ScheduledExecutorService timer=Executors.newScheduledThreadPool(1);
timer.scheduleAtFixedRate(
new Runnable(){
public void run(){
System.out.println("--来了--");
currentLamp=currentLamp.blackOut();
}
},
10,
10,
TimeUnit.SECONDS);
}
}
public class MainClass {
public static void main(String[] args) {
String[] directions = new String[] { "S2N", "S2W", "E2W", "E2S", "N2S",
"N2E", "W2E", "W2N", "S2E", "E2N", "N2W", "W2S" };
for(int i=0;i<directions.length;i++){
new Road(directions);
}
new lampController();
}