org.vizzini.game.action
Class AbstractAction

java.lang.Object
  extended by org.vizzini.game.action.AbstractAction
All Implemented Interfaces:
Serializable, Comparable, IAction
Direct Known Subclasses:
AbstractGridBoardAction, Action, DefaultAction, DiscardAction, DrawAction, RedoAction, TakeDiscardAction, UndoAction

public abstract class AbstractAction
extends Object
implements IAction

Provides base functionality for actions in the game framework. An action instance encapsulates the information necessary for the environment to process the action. Examples are moving a chess piece, moving a paddle to hit a ball, or playing a card.

This class participates in the Command pattern as described in Patterns In Java Volume 1, Mark Grand, 1998.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
AbstractAction()
          Construct this object.
 
Method Summary
 void clear()
          Clear the properties of this object.
 int compareTo(Object object)
          Compare this to the given object.
 boolean doIt()
          Perform the command encapsulated by this object.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 IAgent getAgent()
          Return the agent who originated this action.
 int getRating()
          Return the rating of this action.
 int hashCode()
          Returns a hash code value for the object.
 String prettyPrint()
          Provide a nicely formatted string representation of this object.
 void release()
          Return this instance to the reusable object pool, if one is used.
 void setAgent(IAgent agent)
          Set the agent who originated this action.
 void setRating(int rating)
          Set the rating of this action.
 String toString()
          Return a string representation of this object.
 boolean undoIt()
          Undo the last invocation of doIt.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractAction

public AbstractAction()
Construct this object.

Since:
v0.2
Method Detail

clear

public void clear()
Clear the properties of this object.

Specified by:
clear in interface IAction
Since:
v0.3

compareTo

public int compareTo(Object object)
Compare this to the given object.

Specified by:
compareTo in interface Comparable
Returns:
-1,0,1 if this is less than, equal to, greater than object.
Throws:
ClassCastException - if another is not an instance of AbstractAction.
Since:
v0.2

doIt

public boolean doIt()
Perform the command encapsulated by this object. This method does nothing, and returns false.

Specified by:
doIt in interface IAction
Returns:
true if successful and can be undone.
Since:
v0.2

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface IAction
Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.1

getAgent

public IAgent getAgent()
Return the agent who originated this action.

Specified by:
getAgent in interface IAction
Since:
v0.1

getRating

public int getRating()
Return the rating of this action.

Specified by:
getRating in interface IAction
Since:
v0.2

hashCode

public int hashCode()
Returns a hash code value for the object.

Specified by:
hashCode in interface IAction
Overrides:
hashCode in class Object
Since:
v0.1

prettyPrint

public String prettyPrint()
Provide a nicely formatted string representation of this object.

Specified by:
prettyPrint in interface IAction
Since:
v0.3

release

public void release()
Return this instance to the reusable object pool, if one is used. The base class method simply clears this object.

Specified by:
release in interface IAction
Since:
v0.3

setAgent

public void setAgent(IAgent agent)
Set the agent who originated this action.

Specified by:
setAgent in interface IAction
Parameters:
agent - The agent who originated this action.
Since:
v0.1

setRating

public void setRating(int rating)
Set the rating of this action.

Specified by:
setRating in interface IAction
Since:
v0.2

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1

undoIt

public boolean undoIt()
Undo the last invocation of doIt. This method does nothing, and returns false.

Specified by:
undoIt in interface IAction
Returns:
true if the undo was successful.
Since:
v0.2


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02