Practice ยท 2 of 3
Find the Leaked Mutability
Badge stores an internal List<String> log of scan events.
The current implementation returns the internal list directly. A caller can
clear() your history without your class knowing.
Fix Badge so that:
- the internal list can never be modified from outside
- scans still accumulate internally via scan(String event)
- history() returns a read-only view
Keep the constructor defensive too: copy the incoming list.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Contract Lab