📄 directiongroup.java
字号:
import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;/** * DirectionGroup class keeps all traffic lights in a direction * * @author Hao Chen * @version 1.0 */public class DirectionGroup { public int lightDirection; TrafficLight[] TrafficLightHolder; LinkedList lights; /** * constructor of direction group, create a directiongroup include all lights * @param lightDirection: the direction of the light set */ public DirectionGroup ( int lightDirection ) { this.lightDirection = lightDirection; lights = new LinkedList(); } /** * Adds a lightto the list of light set made so far. * * @param light - the current light made by the user. */ public void AddLight (TrafficLight light ) { lights.add(light); } /** * get this direction * * @param direction - the current direction */ public int GetDirection () { return lightDirection; } /** * get the last light type in the light set * * @param light - the current light made by the user. */ public TrafficLight GetLastLight () { return (TrafficLight)lights.getLast(); } /** * get the first light type in the light set * * @param light - the current light made by the user. */ public TrafficLight GetFirstLight () { return (TrafficLight)lights.getFirst(); } /** * remove the first light type in the light set * * @param light - the current light made by the user. */ public TrafficLight removeFirst () { return (TrafficLight)lights.removeFirst(); } /** * get the light type in the light set with index * * @param light - the current light made by the user. */ public TrafficLight GetLight (int x) { ; return (TrafficLight)lights.get(x); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -