📄 plane.java.svn-base
字号:
package world;import interfaces.CoPilotInterface;import interfaces.GuiObjectInterface;import interfaces.PilotInterface;import interfaces.PlaneInterface;import agents.PilotAgent;import agents.CoPilotAgent;import base.WorldObject;import base.WorldObjectState;/** * CSCI 201 FAA Project - Spring 2009 - Team 4c * * The AbstractPlane class represents a real world plane. It includes a radio for the * controllers to access the pilot and control functions for the pilot. * * @author Josh Villbrandt */public abstract class Plane extends WorldObject implements PlaneInterface { protected PilotInterface pilot = null; protected PilotInterface coPilot = null; // passengers, flight attendants, control surfaces, etc public Plane() { super(); setupPlaneState(); } public Plane(String name) { super(name); setupPlaneState(); } public Plane(String name, WorldObjectState objectState) { super(name, objectState); } public Plane(String name, WorldObjectState objectState, GuiObjectInterface guiObject) { super(name, objectState, guiObject); } // Plane State Setup protected abstract void setupPlaneState(); // Switch CoPilot to Pilot in event of Pilot Death public void promoteCoPilot() { System.out.println("Pilot " + pilot + " is incapcitated, instating CoPilot " + coPilot); coPilot.setLocalController(pilot.getLocalController()); coPilot.setGroundController(pilot.getGroundController()); pilot = coPilot; System.out.println("Pilot is " + pilot); } // Swithc back to Pilot in even that Pilot is reincarnated public void pilotsBack(PilotInterface pilot) { System.out.println("Pilot has been reincarnated / back from bathroom"); // Get the ground controller from the current pilot, which is the copilot pilot.setGroundController(this.pilot.getGroundController()); this.pilot = pilot; } // Pilot Messaging Interfaces public synchronized PilotInterface msgPilot() { return pilot; } public synchronized PilotInterface msgCoPilot() { return coPilot; } // Controller Interfaces for Pilot public synchronized void ctrlAssumePilotRole(PilotInterface p) { pilot = p; } public synchronized void ctrlAssumeCoPilotRole(PilotInterface cp) { coPilot = cp; } public WorldObjectState ctrlInstrumentWorldObjectState() { return objectState; } /** Radio Interface */ public PilotInterface radio() { return pilot; } /** Gets called when World updates. Calls guiObject.update(). */ /* protected void update() { objectState.update(); if(guiObject != null) { guiObject.draw(name, objectState); } } */ public void update() { objectState.update(); if(pilot instanceof PilotAgent) { if (pilot != null) ((PilotAgent)pilot).release_if_necessary(); } else if (pilot instanceof CoPilotAgent) { if (pilot != null) ((CoPilotAgent)pilot).release_if_necessary(); } } /** Override toString */ public String toString() { String str = "{callsign: " + name; str += ", pilot: "; str += (pilot == null) ? "null" : pilot; str += ", coPilot: "; str += (coPilot == null) ? "null" : coPilot; str += ", objectState: " + objectState; return str + "}"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -