blob: 0007fe3dff085c939342231f8d19f08138bdde7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Nik Johnson
// 2-24-2024
// TA: Andy Ruan
import java.util.*;
// checks Strings for the characters "break" that come BEFORE the characters "//"
public class BreakCheck implements Check {
// if the line being checked has "break" in it
// after removing all single line comments, return a new error (code 2)
// takes line and line number
// returns error inside optional
public Optional<Error> lint(String line, int lineNumber) {
String input = line;
String output = input.replaceAll("//.*", "");
if (output.contains("break")) {
return Optional.of(new Error(2, lineNumber, "we cant use break in this class bro"));
}
return Optional.empty();
}
}
|