|
|
Comp202: Principles of Object-Oriented Programming II
|
Agreed upon other features
public interface IChatSendBall extends IChatData{ /** * Index value used to select the case associated with this host. */ public static final String INDEX = "Send Ball"; /** * Retrieves the chat object associated with the *sender* of this chat data object. * Note that the host for the command that processes this chat data will be of type IChatData<?> * so the host will need to be downcast to IChatJoinRoom to access this method. */ public IBallStrategyFac getStratFac(); }
public interface IBallStrategyFac extends Serializable {
public IUpdateStrategy makeUpdateStrategy();
public IPaintStrategy makePaintStrategy();
public IPerson getPlayer();
public UUID getUUID();
public String getType(); // Earth , harvester, warrior
}
/**
* Interface that hides the implementation of a Ball
*
* The methods in this interface are up to debate.
* Some, such as doKill() are arguably not appropriate
* Likewise for performUpdate()
*/
public interface IBall extends Observer {
public IPerson getPlayer(); public UUID getUUID(); public String getType(); // Earth , harvester, warrior public Point2DDouble getLocation(); public void setRadius(int radius); public int getRadius(); public void setVelocity(Point2DDouble velocity); public Point2DDouble getVelocity(); public void setColor(Color color); public Color getColor(); public IUpdateStrategy getStrategy(); public void setPaintStrategy(IPaintStrategy pstrategy); public IPaintStrategy getPaintStrategy(); public IBallMoveStrategy getMoveStrategy(); public void setMoveStrategy(IBallMoveStrategy s); public void update(Observable o, Object cmd); public void addUpdateCmd(IBallCmd cmd); public void updateState(Graphics g); /** * Run all the commands in the _updateCmdSet and then clear it. * then move the ball */ public void performUpdate(); public void setStrategy(IUpdateStrategy strategy); public void paint(Graphics g); /** * "Kills" this ball by delegating the request to the strategy. * @param force an attack amount less than attacker's mass * @return resultant damage less than or equal to force, nagative value means attacker was hurt. */ public double attack(double force); public IBallEnvironment getEnv(); public double getMass(); public void setMass(double mass); }
public abstract interface IBallEnvironment {
/**
* Get the ball dispatcher used by the system. Used when a ball wants to communicate to all the other balls, e.g. for collisions.
* @return The system ball dispatcher
*/
public abstract IDispatcher getDispatcher();
/**
* Associates a key with a behavior (command).
* When the user presses the given key, the ILambda command will be run.
* The parameter passed to the command will be the key name.
* The return value will be discarded.
* @param keyName The name of the key, as defined by the Java "virtual keys": VK_XXX (The "VK_" is omitted). See the Java documentation under "KeyEvent"
* @param cmd The ILambda command that will be run when the key is pressed.
*/
public abstract void addKeyCmd(String keyName, ILambda cmd);
/**
* Adds a command that will be run to whenever the view requests a display string to be displayed.
* The output of the ILambda.apply must be a String given a String input, where the input is the original string
* on the display. The output is concatenated with all other display commands in the system.
* @param cmd The command used to generate part of the total display string.
*/
public abstract void addDisplayCmd(ILambda cmd);
/**
* Gets the Component that the Balls will be painted on. Note that
* a Component class is also implements the ImageObserver interface.
* @return The Component object upon which the Balls will be painted.
*/
public abstract Component getComponent();
/**
* Get the width of the ball's environment. This is not the same as the width of the entire BallWar frame, but rather
* simply the width of the graphics area in which the balls are moving.
* @return The width of the environment in pixels.
*/
public abstract int getWidth();
/**
* Get the height of the ball's environment. This is not the same as the height of the entire BallWar frame, but rather
* simply the height of the graphics area in which the balls are moving.
* @return The height of the environment in pixels.
*/
public abstract int getHeight();
/**
* Get the currently selected player. Note that in general, for a ball or strategy to maintain a
* connection to a particular player, they must save their own reference and not rely on the
* currently selected player. Usually this method is only called during an initialization phase.
* @return The currently selected player.
*/
public abstract double getDeltaTime();
public abstract IPlayer getSelectedPlayer();
/**
* Takes an IMovementKeys object which defines a set of movement keys and
* associates the pressing of each key with its respective behavior in the given IMoveable
* object.
* @param keys The IMovementKeys object that defines a set of movement keys.
* @param m The IMoveable object that is to be associated with the key set.
*/
public abstract void registerMovementKeys(IMovementKeys keys, IMoveable m);
}
John, Mark, and James:
Last Revised Thursday, 03-Jun-2010 09:52:31 CDT
©2007 Stephen Wong and Dung Nguyen