JTP
Class Tile

java.lang.Object
  extended by JTP.Tile
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
GrvTile, IceTile, StartableTile, TptTile

public class Tile
extends Object
implements Serializable

Serves as parent for all types of tile. Most methods described here are overloaded.

Author:
V.Termanis
See Also:
Serialized Form

Field Summary
static int ARROW
          Only allows movement in certain directions.
static int GRAVITY
          Exerts force on surrounding tiles
protected  int height
          Height of this pile
static int ICE
          Slides to adjacent tile.
static int NORMAL
          A normal tile.
static int TELEPORT
          Teleports to another tile.
protected  int type
          One of NORMAL, ICE, TELEPORT, GRAVITY or ARROW
 
Constructor Summary
Tile()
           
 
Method Summary
 Tile copy()
          Creates an exact (non-shallow) copy of the current tile
 boolean decHeight()
          Reduces height of pile by one (to at most 1).
 boolean equalsApartFromHeight(Tile t)
          Used to compare two tiles, ignoring their respective heights.
 int getHeight()
          Returns height of this pile.
 int getType()
          Returns the type of tile.
 void incHeight()
          Increases height of pile.
 boolean isStartable()
          Specifies whether this can be a start tile.
 void setHeight(int height)
          Sets height of tile.
protected  void tileCheck()
          Used to check for tile attribute validity upon creation.
protected  void transferAttributesFrom(Tile tile)
          Used to apply all attributes to this tile from another one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
A normal tile.

See Also:
Constant Field Values

ICE

public static final int ICE
Slides to adjacent tile.

See Also:
Constant Field Values

TELEPORT

public static final int TELEPORT
Teleports to another tile.

See Also:
Constant Field Values

GRAVITY

public static final int GRAVITY
Exerts force on surrounding tiles

See Also:
Constant Field Values

ARROW

public static final int ARROW
Only allows movement in certain directions.

See Also:
Constant Field Values

height

protected int height
Height of this pile


type

protected int type
One of NORMAL, ICE, TELEPORT, GRAVITY or ARROW

Constructor Detail

Tile

public Tile()
Method Detail

tileCheck

protected void tileCheck()
                  throws TileException
Used to check for tile attribute validity upon creation.

Throws:
TileException - if one or more attributes are invalid for a particular tile type.

transferAttributesFrom

protected void transferAttributesFrom(Tile tile)
Used to apply all attributes to this tile from another one.

Parameters:
tile - the Tile instance from which to get attributes.

getType

public int getType()
Returns the type of tile.

Returns:
one of NORMAL, ICE, TELEPORT, GRAVITY or ARROW.

getHeight

public int getHeight()
Returns height of this pile.

Returns:
height of pile in as an int.

decHeight

public boolean decHeight()
Reduces height of pile by one (to at most 1).

Returns:
true if the height was reduced.

incHeight

public void incHeight()
Increases height of pile.


setHeight

public void setHeight(int height)
Sets height of tile.

Parameters:
height - to which to set this pile to. Note: If a height below 1 is specified the height will still be set to one.

isStartable

public boolean isStartable()
Specifies whether this can be a start tile. Not all types of tile can be a start (e.g. ICE).

Returns:
true if this can be a start tile.

equalsApartFromHeight

public boolean equalsApartFromHeight(Tile t)
Used to compare two tiles, ignoring their respective heights.

Parameters:
t - the Tile instance to compare the current tile with.
Returns:
true if the two Tile instances are equal disregarding their heights.

copy

public Tile copy()
Creates an exact (non-shallow) copy of the current tile

Returns:
a copy of the Tile instance.