de.palmmedia.yahtzee.game.elements
Class Element

java.lang.Object
  extended by de.palmmedia.yahtzee.game.elements.Element
Direct Known Subclasses:
Chance, FullHouse, Number, OneKind, Straight

public abstract class Element
extends Object

Represents an element.

Author:
Daniel Palme

Field Summary
private  String name
          The name of the element.
private  Integer result
          The result.
 
Constructor Summary
protected Element(String name)
          Constructor.
 
Method Summary
protected abstract  boolean areDicesAllowed(Dice[] dices)
          Determines whether the dices can be applied to the element.
 int calculate(Dice[] dices)
          Calculates the result of the given dices respecting the allowed state.
protected abstract  int calculateResult(Dice[] dices)
          Calculates the result of the given dices.
 boolean doDicesFit(Dice[] dices)
          Determines whether the dices fit.
 String getName()
          Gets the name.
 Integer getResult()
          Gets the result.
 boolean hasResult()
          Determines whether the element has a result.
 void setDices(Dice[] dices)
          Apply the given dices.
 void unsetDices()
          Reset the element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

private Integer result
The result.


name

private String name
The name of the element.

Constructor Detail

Element

protected Element(String name)
Constructor.

Parameters:
name - The name of the element.
Method Detail

getResult

public Integer getResult()
Gets the result.

Returns:
The result.

hasResult

public boolean hasResult()
Determines whether the element has a result.

Returns:
The result state.

getName

public String getName()
Gets the name.

Returns:
The name.

unsetDices

public void unsetDices()
Reset the element.


setDices

public void setDices(Dice[] dices)
Apply the given dices.

Parameters:
dices - The dices.

calculate

public int calculate(Dice[] dices)
Calculates the result of the given dices respecting the allowed state.

Parameters:
dices - The dices.
Returns:
The result.

doDicesFit

public boolean doDicesFit(Dice[] dices)
Determines whether the dices fit.

Parameters:
dices - The dices.
Returns:
The fit state.

areDicesAllowed

protected abstract boolean areDicesAllowed(Dice[] dices)
Determines whether the dices can be applied to the element.

Parameters:
dices - The dices.
Returns:
The fit state.

calculateResult

protected abstract int calculateResult(Dice[] dices)
Calculates the result of the given dices.

Parameters:
dices - The dices.
Returns:
The result.