3 import java
.rmi
.RemoteException
;
4 import java
.rmi
.server
.UnicastRemoteObject
;
5 import java
.util
.HashMap
;
9 * Applications reparties
13 * Classe d'un futur objet serveur (servant) de l'application chaine d'hotels
18 public class ChaineHotels
{ //TODO completer la declaration de la classe
20 //TODO completer la declaration de chaque methode
22 private static final long serialVersionUID
= -2066714609302506667L;
24 HashMap
<Integer
, Infos
> lesReservations
= null;
27 public ChaineHotels() {
28 this.lesReservations
= new HashMap
<Integer
, Infos
>();
32 public void annuler(int numReservation
) {
33 if(this.lesReservations
.containsKey(new Integer(numReservation
))==false)
34 throw new ExceptionNumReservation();
35 else this.lesReservations
.remove(new Integer(numReservation
));
38 public Infos
lister(int numReservation
) {
39 if(this.lesReservations
.containsKey(new Integer(numReservation
))==false)
40 throw new ExceptionNumReservation();
41 else return this.lesReservations
.get(new Integer(numReservation
));
44 public int reserver(String nomClient
, String nomHotel
, String date
, int nbchambres
) {
45 //il faudrait verifier que les chambres sont disponibles...
46 Infos infos
= new Infos(nomClient
, nomHotel
, date
, nbchambres
);
48 if(this.lesReservations
.put(new Integer(this.numLibre
), infos
) == null) return 0;
49 else return this.lesReservations
.size();