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

Method parkStartingAtSpot

java/Chapter 8/Question8_4/Level.java:46–54  ·  view source on GitHub ↗
(int spotNumber, Vehicle vehicle)

Source from the content-addressed store, hash-verified

44
45 /* Park a vehicle starting at the spot spotNumber, and continuing until vehicle.spotsNeeded. */
46 private boolean parkStartingAtSpot(int spotNumber, Vehicle vehicle) {
47 vehicle.clearSpots();
48 boolean success = true;
49 for (int i = spotNumber; i < spotNumber + vehicle.spotsNeeded; i++) {
50 success &= spots[i].park(vehicle);
51 }
52 availableSpots -= vehicle.spotsNeeded;
53 return success;
54 }
55
56 /* find a spot to park this vehicle. Return index of spot, or -1 on failure. */
57 private int findAvailableSpots(Vehicle vehicle) {

Callers 1

parkVehicleMethod · 0.95

Calls 2

clearSpotsMethod · 0.80
parkMethod · 0.80

Tested by

no test coverage detected