Created
September 28, 2021 11:55
-
-
Save freakinbook/2bb3d513a248d4af5c68900c8996f6ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String printTextPerRole(String[] roles, String[] textLines) { | |
StringBuilder sb = new StringBuilder(); | |
for (String role : roles){ | |
sb.append(role + ":\n"); | |
for (int line = 0; line < textLines.length; line++){ | |
int indexOfColon = textLines[line].indexOf(":"); | |
String roleInLine = textLines[line].substring(0,indexOfColon); | |
if (role.equalsIgnoreCase(roleInLine)){ | |
int lineNumInScript = line + 1; | |
int indexOfSpeech = indexOfColon+1; | |
String speech = textLines[line].substring(indexOfSpeech); | |
sb.append(lineNumInScript + ")" + speech +"\n"); | |
} | |
} | |
sb.append("\n"); | |
} | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment