code: public String getMessagesForDisplay() {
          if(messages.isEmpty()) {
              return "";
          }
          StringBuilder stringBuilder = new StringBuilder();
          for (String message : messages) {
              stringBuilder.append(message);
              stringBuilder.append("\n");
          }
          String tempStr = stringBuilder.toString();
          stringBuilder.deleteCharAt(tempStr.length() - 1);
          return stringBuilder.toString();
      }
docs: Formats the messages in the result to a suitable form
  so that it can be used in user interface.
  
  @return a string containing the formatted message.