mahjong
Class Tile

java.lang.Object
  extended by mahjong.Tile
All Implemented Interfaces:
java.lang.Comparable<Tile>

public class Tile
extends java.lang.Object
implements java.lang.Comparable<Tile>

A single tile within the game. Tiles are unique only by their group value and subindex within that group---there should never two tiles with the same group and subindex.


Field Summary
private  int subindex
          Index within the group (0-3).
private  int value
          Group value.
private  int x
          Position in tile array.
private  int y
          Position in tile array.
private  int z
          Position in tile array.
 
Constructor Summary
Tile(int val, int index)
          Tile constructor.
 
Method Summary
 int compareTo(Tile t)
          Interface method.
 boolean equals(java.lang.Object obj)
           
 int getSubindex()
           
 int getValue()
           
 int getX()
           
 int getY()
           
 int getZ()
           
 int hashCode()
           
 boolean matches(Tile t)
          Checks if this tile is a matching tile for the given one.
 void setCoord(int z1, int y1, int x1)
          Set location in the board.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

private int value
Group value.


subindex

private int subindex
Index within the group (0-3).


z

private int z
Position in tile array.


y

private int y
Position in tile array.


x

private int x
Position in tile array.

Constructor Detail

Tile

public Tile(int val,
            int index)
Tile constructor.

Parameters:
val - group value.
index - sub-index within the group.
Method Detail

setCoord

public void setCoord(int z1,
                     int y1,
                     int x1)
Set location in the board.

Parameters:
z1 - z-coord.
y1 - y-coord.
x1 - x-coord.

getZ

public int getZ()
Returns:
the z

getY

public int getY()
Returns:
the y

getX

public int getX()
Returns:
the x

getValue

public int getValue()
Returns:
the group value

getSubindex

public int getSubindex()
Returns:
the subindex

compareTo

public int compareTo(Tile t)
Interface method.

Specified by:
compareTo in interface java.lang.Comparable<Tile>
Parameters:
t - The Tile to compare to.
Returns:
-1, 0, or 1.
See Also:
Comparable.compareTo(java.lang.Object)

matches

public boolean matches(Tile t)
Checks if this tile is a matching tile for the given one.

Parameters:
t - Tile to check.
Returns:
true if this tile matches the input, false otherwise.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object