+package hotel;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.HashMap;
+
+
+/**
+ * Applications reparties
+ * TP - Exercice
+ * Chaine d'hotels
+ *
+ * Classe d'un futur objet serveur (servant) de l'application chaine d'hotels
+ *
+ * @author Toto
+ * @version 1.0
+ */
+public class ChaineHotels { //TODO completer la declaration de la classe
+
+ //TODO completer la declaration de chaque methode
+
+ private static final long serialVersionUID = -2066714609302506667L;
+
+ HashMap<Integer, Infos> lesReservations = null;
+ Integer numLibre;
+
+ public ChaineHotels() {
+ this.lesReservations = new HashMap<Integer, Infos>();
+ this.numLibre = 0;
+ }
+
+ public void annuler(int numReservation) {
+ if(this.lesReservations.containsKey(new Integer(numReservation))==false)
+ throw new ExceptionNumReservation();
+ else this.lesReservations.remove(new Integer(numReservation));
+ }
+
+ public Infos lister(int numReservation) {
+ if(this.lesReservations.containsKey(new Integer(numReservation))==false)
+ throw new ExceptionNumReservation();
+ else return this.lesReservations.get(new Integer(numReservation));
+ }
+
+ public int reserver(String nomClient, String nomHotel, String date, int nbchambres) {
+ //il faudrait verifier que les chambres sont disponibles...
+ Infos infos = new Infos(nomClient, nomHotel, date, nbchambres);
+ this.numLibre++;
+ if(this.lesReservations.put(new Integer(this.numLibre), infos) == null) return 0;
+ else return this.lesReservations.size();
+ }
+
+}