⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directiongroup.java

📁 交通灯路口的一个小程序,控制四个灯,其中南灯有一个外加左转灯
💻 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 + -