public class Yahtzee extends Object
Modifier and Type | Field and Description |
---|---|
static int |
NUMBER_OF_DICE
The number of six-sided dice used in a standard game of Yahtzee.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isFiveOfAKind(List<Die> dice)
Returns
true if the list contains a five of a kind. |
static boolean |
isFourOfAKind(List<Die> dice)
Returns
true if the list contains a four of a kind. |
static boolean |
isFullHouse(List<Die> dice)
Returns
true if the list contains a full house. |
static boolean |
isLargeStraight(List<Die> dice)
Returns
true if the list contains a large straight. |
static boolean |
isSmallStraight(List<Die> dice)
Returns
true if the list contains a small straight. |
static boolean |
isThreeOfAKind(List<Die> dice)
Returns
true if the list contains a three of a kind. |
static void |
main(String[] args)
Performs a simulation to compute the odds of rolling each of the
Yahtzee categories.
|
public static final int NUMBER_OF_DICE
public static boolean isThreeOfAKind(List<Die> dice)
true
if the list contains a three of a kind.
A three of a kind is defined as at least three dice having the same value.
dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a three of a kindpublic static boolean isFourOfAKind(List<Die> dice)
true
if the list contains a four of a kind.
A four of a kind is defined as at least four dice having the same value.
dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a four of a kindpublic static boolean isFiveOfAKind(List<Die> dice)
true
if the list contains a five of a kind.
A five of a kind is defined as all five dice having the same value.
dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a five of a kindpublic static boolean isFullHouse(List<Die> dice)
true
if the list contains a full house.
A full house is defined as having two dice of the
same value and three dice of the same value.dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a full housepublic static boolean isSmallStraight(List<Die> dice)
true
if the list contains a small straight.
A small straight is defined as at least four dice in sequential order.
dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a small straightpublic static boolean isLargeStraight(List<Die> dice)
true
if the list contains a large straight.
A large straight is defined as five dice in sequential order.
dice
- list of dicedice.size() == Yahtzee.NUMBER_OF_DICE
true
if the list contains a large straightpublic static void main(String[] args)
args
- not used