コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * 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);
     }
   }
 }