be.madoka.aardbei.sokoban.logic
Class Piece

java.lang.Object
  |
  +--be.madoka.aardbei.sokoban.logic.Piece
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, java.beans.VetoableChangeListener
Direct Known Subclasses:
EmptyPiece, HeroPiece, TreasurePiece

public abstract class Piece
extends java.lang.Object
implements java.beans.PropertyChangeListener, java.beans.VetoableChangeListener

Represents an item that can exist in a World.

Author:
Tim Van Wassenhove

Constructor Summary
Piece(Position position)
          Default constructor.
 
Method Summary
 void addPropertyListener(java.beans.PropertyChangeListener pcl)
          Adds the given PropertyListener.
 void addVetoableChangeListener(java.beans.VetoableChangeListener vcl)
          Adds the given VetoAbleChangeListener.
 int getMoves()
          Gives the number moves this Piece has made.
abstract  java.lang.String getName()
          Returns the name of this Piece.
 Position getOldPosition()
          Returns the previous Position of this Piece.
 Position getPosition()
          Returns the Position of this Piece.
 boolean move(int direction)
          Moves into the given direction.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 void removePropertyListener(java.beans.PropertyChangeListener pcl)
          Removes the given PropertyListener.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener vcl)
          Removes the given VetoAbleChangeListener.
 void vetoableChange(java.beans.PropertyChangeEvent e)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Piece

public Piece(Position position)
Default constructor.

Parameters:
position - the Position
Method Detail

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener vcl)
Adds the given VetoAbleChangeListener.

Parameters:
vcl - the VetoAbleChangeListener

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener vcl)
Removes the given VetoAbleChangeListener.

Parameters:
vcl - the VetoAbleChangeListener

addPropertyListener

public void addPropertyListener(java.beans.PropertyChangeListener pcl)
Adds the given PropertyListener.

Parameters:
pcl - the PropertyListener

removePropertyListener

public void removePropertyListener(java.beans.PropertyChangeListener pcl)
Removes the given PropertyListener.

Parameters:
pcl - the PropertyListener

getName

public abstract java.lang.String getName()
Returns the name of this Piece.

Returns:
a String specifying the name of this Piece

getPosition

public Position getPosition()
Returns the Position of this Piece.

Returns:
a Position specifying the Position of this Piece

getOldPosition

public Position getOldPosition()
Returns the previous Position of this Piece.

Returns:
a Position specifying the previous Position of this Piece

move

public boolean move(int direction)
Moves into the given direction.

Parameters:
direction - the direction
Returns:
a boolean/ specifying if the move was succesfull or not

getMoves

public int getMoves()
Gives the number moves this Piece has made.

Returns:
an int specifying the number of moves

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent e)
                    throws java.beans.PropertyVetoException
Specified by:
vetoableChange in interface java.beans.VetoableChangeListener
java.beans.PropertyVetoException