public MyRentController() { Car car = new Car(); car.setPlateNumber("11AA22"); car.setRented(false); cars.add(car); car = new Car(); car.setPlateNumber("22BB33"); car.setRented(false); cars.add(car); }
/** * Rent a car. * * @param plateNumber * @return car specifications * @throws Exception no car with this plate number or already rented */ @RequestMapping(value = "/car/{plateNumber}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Override public void rentCar(@PathVariable("plateNumber") String plateNumber) throws Exception { List<CarDTO> dtos = new ArrayList<CarDTO>(); Car car; for (int i = 0; i < cars.size(); i++) { // parcours BDD car = cars.get(i); // extrait ième voiture if (car.getPlateNumber().equals(plateNumber)) { car.setRented(true); } } }