以下是一个D2jsp Yamb 游戏的最终实例,展示了如何使用D2jsp编写一个简单的Yamb游戏。

```java

public class YambGame {

private int[] diceValues;

private int score;

public YambGame() {

diceValues = new int[5];

score = 0;

}

public void rollDice() {

for (int i = 0; i < diceValues.length; i++) {

diceValues[i] = (int) (Math.random() * 6) + 1;

}

}

public void calculateScore() {

score = 0;

int ones = 0, twos = 0, threes = 0, fours = 0, fives = 0, sixes = 0;

int pair = 0, threeOfAKind = 0, fourOfAKind = 0, straight = 0, fullHouse = 0;

int smallStraight = 0, largeStraight = 0;

for (int value : diceValues) {

switch (value) {

case 1:

ones++;

break;

case 2:

twos++;

break;

case 3:

threes++;

break;

case 4:

fours++;

break;

case 5:

fives++;

break;

case 6:

sixes++;

break;

}

}

if (ones >= 1) {

score += ones;

}

if (twos >= 2) {

score += 2;

pair = 2;

}

if (threes >= 3) {

score += 3;

threeOfAKind = 3;

}

if (fours >= 4) {

score += 4;

fourOfAKind = 4;

}

if (fives >= 5) {

score += 5;

smallStraight = 5;

}

if (sixes >= 6) {

score += 6;

largeStraight = 6;

}

if (pair == 2 && threeOfAKind == 3) {

score += 5;

fullHouse = 5;

}

if (smallStraight == 5 && largeStraight == 6) {

score += 7;

straight = 7;

}

}

public int getScore() {

return score;

}

public void printDiceValues() {

System.out.println("