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

📄 vehicle.java

📁 现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为project的文件里.安装好后用bluej打开peoject的例子,可以进行你想要的任何变化.同时可以了解大量的源码
💻 JAVA
字号:
/** * Capture outline details of a vehicle. *  * @author David J. Barnes and Michael Kolling * @version 2006.03.30 */public abstract class Vehicle{    private TaxiCompany company;    // Where the vehicle is.    private Location location;    // Where the vehicle is headed.    private Location targetLocation;        /**     * Constructor of class Vehicle     * @param company The taxi company. Must not be null.     * @param location The vehicle's starting point. Must not be null.     * @throws NullPointerException If company or location is null.     */    public Vehicle(TaxiCompany company, Location location)    {        if(company == null) {            throw new NullPointerException("company");        }        if(location == null) {            throw new NullPointerException("location");        }        this.company = company;        this.location = location;        targetLocation = null;    }        /**     * Notify the company of our arrival at a pickup location.     */    public void notifyPickupArrival()    {        company.arrivedAtPickup(this);    }        /**     * Notify the company of our arrival at a     * passenger's destination.     * @param passenger The passenger who has arrived.     */    public void notifyPassengerArrival(Passenger passenger)    {        company.arrivedAtDestination(this, passenger);    }        /**     * Receive a pickup location.     * How this is handled depends on the type of vehicle.     * @param location The pickup location.     */    public abstract void setPickupLocation(Location location);        /**     * Receive a passenger.     * How this is handled depends on the type of vehicle.     * @param passenger The passenger being picked up.     */    public abstract void pickup(Passenger passenger);        /**     * @return Whether or not this vehicle is free.     */    public abstract boolean isFree();        /**     * Offload any passengers whose destination is the     * current location.     */    public abstract void offloadPassenger();        /**     * @return Where this vehicle is currently located.     */    public Location getLocation()    {        return location;    }        /**     * Set the current location.     * @param location Where it is. Must not be null.     * @throws NullPointerException If location is null.     */    public void setLocation(Location location)    {        if(location != null) {            this.location = location;        }        else {            throw new NullPointerException();        }    }        /**     * @return Where this vehicle is currently headed, or null     *         if it is idle.     */    public Location getTargetLocation()    {        return targetLocation;    }        /**     * Set the required target location.     * @param location Where to go. Must not be null.     * @throws NullPointerException If location is null.     */    public void setTargetLocation(Location location)    {        if(location != null) {            targetLocation = location;        }        else {            throw new NullPointerException();        }    }        /**     * Clear the target location.     */    public void clearTargetLocation()    {        targetLocation = null;    }}

⌨️ 快捷键说明

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