/** * Iterates through all the parking lots until it finds one that is not occupied. * * @return The first unoccupied <em>ParkingSpot<T></em> it finds in the parking lot. This method * throws an <em>IllegalStateException</em> in case there are no available parking spots. */ private ParkingSpot<T> getFreeSpot() { ParkingSpot<T> spot = null; for (ParkingSpot<T> sc : parkingLot) { if (!sc.isOccupied()) { spot = sc; break; } } if (spot == null) { throw new IllegalStateException("The parking lot is full!"); } return spot; }