git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@80 72836036-5685-4462-b002-a69064685172
82 lines
1.4 KiB
Java
82 lines
1.4 KiB
Java
package jrummikub.model;
|
|
|
|
/** Basic Rummikub Stone */
|
|
|
|
public class Stone implements Sizeable {
|
|
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 "Stone[joker,color=" + color + "]";
|
|
} else {
|
|
return "Stone[value=" + value + ",color=" + color + "]";
|
|
}
|
|
}
|
|
}
|