runway.java

来自「一个飞机调度员模拟训练程序,可以添加跑道数量,控制飞机飞行的速度.默认的密码可以」· Java 代码 · 共 97 行

JAVA
97
字号
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.InterruptedException;
import java.awt.geom.Line2D.Float;
/**
 * A simulated runway.
 * 
 * @author James M. Clarke  
 * @version 02/03/2007
 */
public class Runway
{
    // instance variables - replace the example below with your own
    private Position start;
    private Position end;
    private float angle;
    private String name;

    /**
	 * Constructor for Runway objects
	 * @param  where  the starting point of the runway, that is, the point at which planes approaching it must pass through
	 * @param  direction  the direction in which the runway points, in radians clockwise from the y-axis
	 */
    public Runway(Position where, float direction, String inName)
    {       
        start = where;
        angle = direction;
        end = Position.atAngleDistance(start, angle, 30);
        name = inName;
    }

    /**
     * Draws the runway so it can be displayed
     * 
     * @param  graphic a Graphics2D to draw the runway onto
     */
    public void draw(Graphics2D graphic)
    {
            // Draw on the runway
            graphic.draw( new java.awt.geom.Line2D.Float( start.getX(), start.getY(), end.getX(), end.getY()) );
    }

     /**
	 * Accessor method for the position of the start of the runway
	 * 
	 * @return     Position of the start of the runway
	 */    
    public Position getPosition()
    {
        return start;
    }

     /**
	 * Accessor method for the position of the end of the runway
	 * 
	 * @return     Position of the end of the runway
	 */    
    public Position getEnd()
    {
        return end;
    }

     /**
	 * Accessor method for the angle in which the runway points
	 * 
	 * @return     Angle in which the runway points, in radians clockwise from the y-axis
	 */      
    public float getAngle()
    {
        return angle;
    }

    
     /**
	 * Accessor method for the angle in which the runway points
	 * 
	 * @return     Angle in which the runway points, in radians clockwise from the y-axis
	 */      
    public String getName()
    {
        return name;
    }
    
     /**
	 * Accessor method for the angle in which the runway points
	 * 
	 * @return     Angle in which the runway points, in radians clockwise from the y-axis
	 */      
    public String toString()
    {
        return name;
    }    
    
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?