Skip to main content

Checkpoint: the hostile-reviewer Session

Challenge on lesson: Checkpoint: Hostile-Reviewer Session

Implement static final class Session + helper: 1. Constructor Session(List<String> events) — defensively copies. 2. events() returns an unmodifiable view; add(String e) mutates internal state only. 3. String describe() returns "Session[n]" with n = current event count. 4. static String safeTrace() — creates a Session from a mutable list, mutates that external list afterwards, then returns the Session's describe() value. The tests simulate all three hostile reviewers.

Difficulty: advanced

Back to lesson: Checkpoint: Hostile-Reviewer Session