Night_Wolf17

printTextPerRoles

Mar 17th, 2021 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public static String printTextPerRole(String[] roles, String[] textLines) {
  2.     StringBuilder sb = new StringBuilder();
  3.     for (String role : roles) {
  4.         sb.append(role + ":\n");
  5.         for (int i = 0; i < textLines.length; i++) {
  6.             if (textLines[i].startsWith(role + ":")) {
  7.                 sb.append((i + 1) + ")" + textLines[i].substring(role.length() + 1) + "\n");
  8.             }
  9.         }
  10.         sb.append("\n");
  11.     }
  12.     return sb.toString();
  13. }
Add Comment
Please, Sign In to add comment