private StringBuilder buildLineClue(StringBuilder sb, KoanSuiteResult result) { if (result.getLineNumber() != null && result.getLineNumber().trim().length() != 0) { sb.append(Strings.getMessage("line")) .append(" ") .append(result.getLineNumber()) .append(" ") .append(Strings.getMessage("may_offer_clue")); } return sb; }
protected void displayPassingFailing(KoanSuiteResult result) { StringBuilder sb = new StringBuilder(); appendLabeledClassesList( Strings.getMessage("passing_suites") + ":", result.getPassingSuites(), sb); appendLabeledClassesList( Strings.getMessage("remaining_suites") + ":", result.getRemainingSuites(), sb); sb.append(EOL) .append("Edit & save a koan") .append( ApplicationSettings.isInteractive() ? " to test your progress, or enter '" + ApplicationSettings.getExitChar() + "' to exit." : ", then rerun to test your progress"); displayMessage(sb.toString()); }
private StringBuilder buildInvestigateLine( StringBuilder sb, String simpleName, String methodName) { return sb.append(Strings.getMessage("investigate")) .append(": ") .append(simpleName) .append(" class's ") .append(methodName) .append(" method."); }
@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()); }
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()); }
@Override protected void displayAllSuccess(KoanSuiteResult result) { displayMessage( new StringBuilder(EOL).append(Strings.getMessage("all_koans_succeeded")).toString()); }