Skip to main content

Checkpoint: the locker room

Challenge on lesson: Checkpoint: lowest-free allocation

CHALLENGE
Difficulty: advanced+25 XP

Implement the Locker class: constructor takes the number of lockers. claim(name) assigns the **lowest-numbered free locker** to name and returns the locker number (1-based), or -1 when full. release(num) frees that locker (silently ignoring invalid or already-free numbers). owner(num) returns the current owner's name or null. Use an array of String.

Back to lesson: Checkpoint: lowest-free allocation