TD3: Add code skeleton for the hostel reservations though RMI.
[TD_SR.git] / TD3 / hotel / ChaineHotels.java
1 package hotel;
2
3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
5 import java.util.HashMap;
6
7
8 /**
9 * Applications reparties
10 * TP - Exercice
11 * Chaine d'hotels
12 *
13 * Classe d'un futur objet serveur (servant) de l'application chaine d'hotels
14 *
15 * @author Toto
16 * @version 1.0
17 */
18 public class ChaineHotels { //TODO completer la declaration de la classe
19
20 //TODO completer la declaration de chaque methode
21
22 private static final long serialVersionUID = -2066714609302506667L;
23
24 HashMap<Integer, Infos> lesReservations = null;
25 Integer numLibre;
26
27 public ChaineHotels() {
28 this.lesReservations = new HashMap<Integer, Infos>();
29 this.numLibre = 0;
30 }
31
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));
36 }
37
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));
42 }
43
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);
47 this.numLibre++;
48 if(this.lesReservations.put(new Integer(this.numLibre), infos) == null) return 0;
49 else return this.lesReservations.size();
50 }
51
52 }