MCPcopy Index your code
hub / github.com/careercup/ctci / parkVehicle

Method parkVehicle

java/Chapter 8/Question8_4/Level.java:34–43  ·  view source on GitHub ↗
(Vehicle vehicle)

Source from the content-addressed store, hash-verified

32
33 /* Try to find a place to park this vehicle. Return false if failed. */
34 public boolean parkVehicle(Vehicle vehicle) {
35 if (availableSpots() < vehicle.getSpotsNeeded()) {
36 return false;
37 }
38 int spotNumber = findAvailableSpots(vehicle);
39 if (spotNumber < 0) {
40 return false;
41 }
42 return parkStartingAtSpot(spotNumber, vehicle);
43 }
44
45 /* Park a vehicle starting at the spot spotNumber, and continuing until vehicle.spotsNeeded. */
46 private boolean parkStartingAtSpot(int spotNumber, Vehicle vehicle) {

Callers

nothing calls this directly

Calls 4

availableSpotsMethod · 0.95
findAvailableSpotsMethod · 0.95
parkStartingAtSpotMethod · 0.95
getSpotsNeededMethod · 0.80

Tested by

no test coverage detected