예제 #1
0
  public Price getMedianJudgedValue(int round) throws ScoreException {
    Quantity totalValue = Quantity.ZERO;
    int judgeCount = 0;
    for (Iterator iterator = playerNameIterator(); iterator.hasNext(); ) {
      Judge judge = getJudgeOrNull((String) iterator.next());
      if (judge == null || judge.isDormant(getCurrentRound())) {
        continue;
      }
      Price estimate = judge.getEstimate(round);
      if (estimate == null) {
        continue;
      }

      totalValue = totalValue.plus(estimate);
      judgeCount += 1;
    }
    if (judgeCount == 0) {
      if (cuttingOffJudges()) {
        return Price.dollarPrice(50);
      }
      String message =
          "Judges have not entered estimates for " + getRoundLabel() + " " + round + ".";
      appendToErrorMessage(message);
      throw new ScoreException(message);
    } else {
      return marketPrice(totalValue.div(judgeCount));
    }
  }