コード例 #1
0
 public int getNumberOfDice(Die die) {
   int number = 0;
   for (Die itemDie : dice) {
     if (itemDie.getType() == die.getType()) {
       number++;
     }
   }
   return number;
 }
コード例 #2
0
  public void setNumberOfDice(Die die, int number) {

    ItemDice tmpDice = new ItemDice();

    for (Die d : dice) {
      if (d.getType() != die.getType()) {
        tmpDice.add(d);
      }
    }
    for (int i = 0; i < number; i++) {
      tmpDice.add(die);
    }
    dice = tmpDice;
  }