/** Drive all cars until they have arrived. */ public void driveCars() { while (cars.size() > 0) { int i = 0; while (i < cars.size()) { Car c = cars.get(i); c.drive(); if (c.hasArrived()) { cars.remove(i); } else { i++; } } } }
/** Drive all cars until they have arrived. */ public void driveCars() { while (cars.size() > 0) { int i = 0; while (i < cars.size()) { Car c = cars.get(i); ArrayList<Person> arrived = c.drive(); // TODO: Add print statement here for (Person passenger : arrived) { System.out.println(c.getDriverName() + " drops off " + passenger.getName()); } if (c.hasArrived()) { cars.remove(i); } else { i++; } } } }