// 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 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(); } }