Skip to content

Commit a288ec3

Browse files
committed
Fix bug with capitalization
1 parent eb8405b commit a288ec3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/textEditor/Capitalizer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ public String capitalize(String s) {
66
if (s.length() > 0) {
77
sb.append(Character.toUpperCase(s.charAt(0)));
88
}
9-
boolean foundTheEndOfLine = false;
9+
boolean foundTheEndOfSentence = false;
1010
for (int i = 1; i < s.length(); i++) {
11-
if (foundTheEndOfLine && !Character.isSpaceChar(s.charAt(i))) {
11+
if (foundTheEndOfSentence && !Character.isWhitespace(s.charAt(i))) {
1212
sb.append(Character.toUpperCase(s.charAt(i)));
13-
foundTheEndOfLine = false;
13+
foundTheEndOfSentence = false;
1414
} else {
1515
sb.append(s.charAt(i));
1616
}
1717
if (s.charAt(i) == '.') {
18-
foundTheEndOfLine = true;
18+
foundTheEndOfSentence = true;
1919
}
2020
}
2121
return sb.toString();

0 commit comments

Comments
 (0)