Example #1
0
 @Transient
 public Integer getNumHabDisponible(Date di, Date df) {
   Integer aux = null;
   for (int i = 0; i < habitacions.size() && aux != null; i++) {
     Habitacio h = habitacions.get(i);
     aux = h.disponible(di, df);
   }
   return aux;
 }
 private void carregaHabitacions() {
   String[] nomsHotels = {
     "Palace", "Hilton", "Metropolitan", "Arts", "Catalunya", "PensiĆ³n Pepe", "Bonjour", "Oulala"
   };
   String[] nomsTipus = {"Individual", "Doble", "Matrimoni"};
   float[] preus = {100, 200, 250};
   for (int i = 0; i < nomsHotels.length; ++i) {
     for (int j = 0; j < nomsTipus.length; ++j) {
       Habitacio h = new Habitacio();
       h.setId(new HabitacioId(nomsHotels[i], j));
       session.persist(h);
     }
   }
 }
Example #3
0
 public float reservaHabitacio(Viatge v, Date di, Date df) {
   Integer numH = getNumHabDisponible(di, df);
   boolean fi = false;
   float preuH = 0;
   for (int i = 0; i < habitacions.size() && fi; i++) {
     Habitacio h = habitacions.get(i);
     int numero = h.getNumero();
     fi = numH == numero;
     if (fi) {
       preuH = getPreu(di, df);
       h.setViatge(v);
     }
   }
   return preuH;
 }