Improve code for moodle verification

This commit is contained in:
Manuel Thalmann 2022-09-28 10:39:28 +02:00
parent cfe533f03b
commit 3f6493694c

View file

@ -37,7 +37,9 @@ public class BracketServer implements CommandExecutor {
for (MatchResult result : results) { for (MatchResult result : results) {
if (bracketPairs.keySet().contains(result.group())) { if (bracketPairs.keySet().contains(result.group())) {
openBrackets.push(result.group()); openBrackets.push(result.group());
} else if (result.group().equals(bracketPairs.get(openBrackets.peek()))) { } else if (
!openBrackets.isEmpty() &&
result.group().equals(bracketPairs.get(openBrackets.peek()))) {
openBrackets.pop(); openBrackets.pop();
} else { } else {
return false; return false;