Skip to main content

Practice · 1 of 3

The parking gate state machine

CHALLENGE
Difficulty: advanced+25 XP

Implement the Parking class: constructor takes the **capacity**. arrive(plate) adds the plate and returns true, unless the lot is **full** — then return false and change nothing. depart(plate) removes the plate and returns true, or returns false if the plate is not parked. count() returns the number of parked cars. Use an ArrayList<String>.

Back to lesson: Practice: State machine lab