Exemplo n.º 1
0
  @Override
  public String getMostPopularCarRentalCompany() {
    String popularCompany = "";
    int nbReservations = 0;

    for (String companyString : this.getAllRentalCompanies()) {

      CarRentalCompany company = em.find(CarRentalCompany.class, companyString);

      int reservationCount = company.getTotalNbReservations();
      if (reservationCount > nbReservations) {
        nbReservations = reservationCount;
        popularCompany = companyString;
      }
    }
    return popularCompany;
  }
Exemplo n.º 2
0
 public void addNewCar(int id, String type, String companyName) {
   CarType carType = em.find(CarType.class, type);
   Car car = new Car(id, carType);
   CarRentalCompany company = em.find(CarRentalCompany.class, companyName);
   company.addCar(car);
 }