be.madoka.aardbei.sokoban.logic
Class World

java.lang.Object
  |
  +--be.madoka.aardbei.sokoban.logic.World
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, java.beans.VetoableChangeListener

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

Represents a World where Pieces can live in.

Author:
Tim Van Wassenhove

Constructor Summary
World(SokoLogic logic, Dimension dimension)
          Default constructor.
 
Method Summary
 boolean add(Piece piece)
          Adds a Piece to this World.
 Piece findPiece(java.lang.String name)
          Returns a Piece with the given name.
 java.util.Vector findPieces(java.lang.String name)
          Returns all the Pieces with the givin name
 Dimension getDimension()
          Gives the Dimension of this World.
 boolean move(int direction)
          Moves all the Pieces into a given direction.
 boolean move(Piece piece, int direction)
          Moves a Piece into a given direction.
 java.util.Vector pieces()
          Returns all the pieces.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 boolean removePiece(Piece piece)
          Removes a given Piece from this World.
 void vetoableChange(java.beans.PropertyChangeEvent e)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

World

public World(SokoLogic logic,
             Dimension dimension)
Default constructor.

Parameters:
logic - the Logic
dimension - the Dimension
Method Detail

move

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

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

move

public boolean move(Piece piece,
                    int direction)
Moves a Piece into a given direction.

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

add

public boolean add(Piece piece)
Adds a Piece to this World.

Parameters:
piece - the Piece
Returns:
a boolean specifying if the Piece was added or not

removePiece

public boolean removePiece(Piece piece)
Removes a given Piece from this World.

Parameters:
piece - the Piece
Returns:
a boolean specifying if the piece was removed or not

getDimension

public Dimension getDimension()
Gives the Dimension of this World.

Returns:
a Dimension specifying the Dimension of this World

pieces

public java.util.Vector pieces()
Returns all the pieces.

Returns:
a Vector containing all the pieces

findPiece

public Piece findPiece(java.lang.String name)
Returns a Piece with the given name.

Parameters:
name - the name
Returns:
a Piece as requested

findPieces

public java.util.Vector findPieces(java.lang.String name)
Returns all the Pieces with the givin name

Parameters:
name - the name
Returns:
a Vector containing all the Pieces

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