Пример #1
0
 @Override
 protected void displayOneOrMoreFailure(KoanSuiteResult result) {
   printSuggestion(result);
   String message = result.getMessage();
   StringBuilder sb = new StringBuilder();
   if (ApplicationSettings.isExpectationResultVisible()) {
     sb.append(
         message == null || message.length() == 0 || !result.displayIncompleteException()
             ? ""
             : new StringBuilder(Strings.getMessage("what_went_wrong"))
                 .append(": ")
                 .append(EOL)
                 .append(message)
                 .append(EOL));
   }
   if (ApplicationSettings
       .isEncouragementEnabled()) { // added noise to console output, and no real value
     int totalKoans = result.getTotalNumberOfKoans();
     int numberPassing = result.getNumberPassing();
     sb.append(EOL)
         .append(Strings.getMessage("you_have_conquered"))
         .append(" ")
         .append(numberPassing)
         .append(" ")
         .append(Strings.getMessage("out_of"))
         .append(" ")
         .append(totalKoans)
         .append(" ")
         .append(totalKoans != 1 ? Strings.getMessage("koans") : Strings.getMessage("koan"))
         .append("! ")
         .append(Strings.getMessage("encouragement"));
   }
   displayMessage(sb.toString());
 }
Пример #2
0
 protected void displayChart(KoanSuiteResult result) {
   StringBuilder sb =
       new StringBuilder(Strings.getMessage("level"))
           .append(": ")
           .append(result.getLevel())
           .append(EOL);
   int numberPassing = result.getNumberPassing();
   int totalKoans = result.getTotalNumberOfKoans();
   double percentPassing = ((double) numberPassing) / ((double) totalKoans);
   int percentScaledToFifty = (int) (percentPassing * PROGRESS_BAR_WIDTH);
   sb.append(Strings.getMessage("progress")).append(" ").append(PROGRESS_BAR_START);
   for (int i = 0; i < PROGRESS_BAR_WIDTH; i++) {
     if (i < percentScaledToFifty) {
       sb.append(KoanConstants.COMPLETE_CHAR);
     } else {
       sb.append(KoanConstants.INCOMPLETE_CHAR);
     }
   }
   sb.append(PROGRESS_BAR_END);
   sb.append(' ');
   sb.append(numberPassing).append("/").append(totalKoans);
   displayMessage(sb.toString());
 }