
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@445 72836036-5685-4462-b002-a69064685172
85 lines
1.4 KiB
Java
85 lines
1.4 KiB
Java
package jrummikub.model;
|
|
|
|
import java.io.Serializable;
|
|
|
|
/** Basic Rummikub Stone */
|
|
|
|
public class Stone implements Sizeable, Serializable {
|
|
private static final long serialVersionUID = 7032593080727812277L;
|
|
|
|
private int value;
|
|
private StoneColor color;
|
|
private final boolean joker;
|
|
|
|
/**
|
|
* Creates a joker of the given color. The color is only used for displaying.
|
|
*
|
|
* @param color
|
|
* joker color
|
|
*/
|
|
public Stone(StoneColor color) {
|
|
this.value = 0;
|
|
this.color = color;
|
|
this.joker = true;
|
|
}
|
|
|
|
/**
|
|
* Creates a normal stone of a given color and value
|
|
*
|
|
* @param value
|
|
* stone value
|
|
* @param color
|
|
* stone color
|
|
*/
|
|
public Stone(int value, StoneColor color) {
|
|
this.value = value;
|
|
this.color = color;
|
|
this.joker = false;
|
|
}
|
|
|
|
/**
|
|
* Returns the color of the stone.
|
|
*
|
|
* @return stone color
|
|
*/
|
|
public StoneColor getColor() {
|
|
return color;
|
|
}
|
|
|
|
/**
|
|
* Returns whether the stone is a joker or not.
|
|
*
|
|
* @return true when the stone is a joker
|
|
*/
|
|
public boolean isJoker() {
|
|
return joker;
|
|
}
|
|
|
|
/**
|
|
* Returns the value of the stone. Don't use this value for jokers.
|
|
*
|
|
* @return stone value
|
|
*/
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public float getWidth() {
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public float getHeight() {
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
if (joker) {
|
|
return "[" + color + " J]";
|
|
} else {
|
|
return "[" + color + " " + value + "]";
|
|
}
|
|
}
|
|
}
|