An alert desk creates one alert and hands it to a formatter for a preview. The formatter uses that alert during one method call and never stores it.
AlertDesk is provided in the starter code. Its behavior is:
String preview(String message, String severity) accepts severities "info", "warning", and "critical"."<SEVERITY>:<message>", with the severity label in uppercase."INVALID" and changes no state.int previewCount() returns the number of successful previews.String lastSeverity() returns the latest successful lowercase severity, or "NONE" initially.AlertDesk is provided in the starter code. Do not modify it. Implement two supporting classes:
Alert stores the message and severity.AlertFormatter.format(Alert alert) builds the output.AlertDesk may retain only the count and last-severity string. It must not retain an Alert or AlertFormatter.
Input:
Output:
Explanation: The alert exists for one call, the formatter consumes it, and the desk retains only the count and severity string.
Input:
Output:
Explanation: Validation fails before an alert or formatter is needed.
0 <= message.length <= 1000 <= severity.length <= 20100 calls are made across all methods.Full marks when AlertFormatter.format receives an Alert parameter and AlertFormatter has no fields. Lose points heavily when the formatter stores an alert or AlertDesk absorbs the formatter responsibility.
Full marks when Alert and the fieldless AlertFormatter expose exactly the constructor and methods used by the provided desk, and the formatter retains no alert. Lose points for incompatible APIs or collaborator fields.
Full marks when AlertFormatter returns the exact uppercase label and message required by the provided desk without printing to stdout or adding unrelated state.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new AlertDesk() | null |
| preview("Disk ready", "info") | "INFO:Disk ready" |
| previewCount() | 1 |
| lastSeverity() | "info" |
A temporary alert is passed into the fieldless formatter, and only result data remains.
Run checks these cases. Submit also runs a larger hidden set.

