diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:22 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:22 -0700 |
| commit | 4a0d047e83141d3ebe48a2bf4ea58e1192a01333 (patch) | |
| tree | 7125d1be1df434ca98a1d08fb4a30ebd28730d19 /linter/Error.java | |
Diffstat (limited to 'linter/Error.java')
| -rw-r--r-- | linter/Error.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/linter/Error.java b/linter/Error.java new file mode 100644 index 0000000..da4a051 --- /dev/null +++ b/linter/Error.java @@ -0,0 +1,43 @@ +// Nik Johnson +// 2-24-2024 +// TA: Andy Ruan + +/* +Defining an object called Error, which has the fields: +code: the errors code, represented by an int +lineNumber: the line where the error occurred +message: a description of the error +*/ +public class Error { + + private int code; + private int lineNumber; + private String message; + + // construct an error with its fields + public Error(int code, int lineNumber, String message) { + this.code = code; + this.lineNumber = lineNumber; + this.message = message; + } + + // format an error and its information nicely + public String toString() { + return ("(Line: " + lineNumber + ") " + "has error code " + code + "\n" + message); + } + + // return line where the error occurs + public int getLineNumber() { + return this.lineNumber; + } + + // return the error code (a number) + public int getCode() { + return this.code; + } + + // return the errors description + public String getMessage() { + return this.message; + } +} |
