コード例 #1
0
  public static String printPersonReturnsToOthersDetails(
      PersonData pp,
      String howMuchPaidText,
      String howMuchShouldPayText,
      String returnToText,
      String forText,
      String endOfLine) {
    //		String currency = Currency.getInstance(Locale.getDefault()).getSymbol();

    StringBuilder sb =
        new StringBuilder(pp.getName())
            .append(" - ")
            .append(howMuchPaidText)
            .append(": ")
            .append(FormatterHelper.currencyFormat(pp.getHowMuchPersonPaid(), 2))
            .append(" ");
    sb.append("(")
        .append(howMuchShouldPayText)
        .append(": ")
        .append(FormatterHelper.currencyFormat(pp.getHowMuchPersonShouldPay(), 2))
        .append(")");

    String messageIfNoReturnNeeded = sb.toString() + endOfLine;

    sb.append(", ").append(returnToText).append(":").append(endOfLine);
    boolean isThereAnyPersonOnReturnList = false;

    Iterator<String> it = pp.getMyDebts().keySet().iterator();
    while (it.hasNext()) {
      String key = it.next();
      double result = pp.getMyDebts().get(key);
      if (result > 0) {
        isThereAnyPersonOnReturnList = true;
        sb.append(FormatterHelper.currencyFormat(result, 2)).append(" ");
        sb.append(forText).append(": ").append(key).append(endOfLine);
      }
    }

    if (isThereAnyPersonOnReturnList) return sb.toString();
    else return messageIfNoReturnNeeded;
  }
コード例 #2
0
  private static String printCalculationList(
      String separator, StringBuilder sb, HashMap<String, Double> paysMap) {
    Iterator<String> it = paysMap.keySet().iterator();
    while (it.hasNext()) {
      String key = it.next();
      double value = paysMap.get(key);
      sb.append(FormatterHelper.currencyFormat(value, 2)).append(" ");
      sb.append(separator).append(": ").append(key).append("\n");
    }

    return sb.toString();
  }
コード例 #3
0
  private static String simplePrinter(
      String prefix, String helpText, HashMap<String, Double> payMap) {
    StringBuilder sb = new StringBuilder();

    boolean first = true;
    Iterator<String> it = payMap.keySet().iterator();
    while (it.hasNext()) {
      String key = it.next();
      double value = payMap.get(key);
      if (value > 0) {
        if (!first) {
          sb.append("\n");
        } else first = false;
        sb.append(prefix)
            .append(FormatterHelper.currencyFormat(value, 2))
            .append(" ")
            .append(helpText)
            .append(": ")
            .append(key);
      }
    }

    return sb.toString();
  }