X-Git-Url: https://git.piment-noir.org/?p=TD_SR.git;a=blobdiff_plain;f=TD3%2Fhotel%2FChaineHotels.java;fp=TD3%2Fhotel%2FChaineHotels.java;h=990cfb7b3075ad25ed85cc39f97b70334ab1f3ac;hp=0000000000000000000000000000000000000000;hb=3a8c8f1926734c79be64af8debbc807ee2eabb5e;hpb=ae09e645684a4f53aad5566f811ab7e99d6b68ac diff --git a/TD3/hotel/ChaineHotels.java b/TD3/hotel/ChaineHotels.java new file mode 100644 index 0000000..990cfb7 --- /dev/null +++ b/TD3/hotel/ChaineHotels.java @@ -0,0 +1,52 @@ +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 lesReservations = null; + Integer numLibre; + + public ChaineHotels() { + this.lesReservations = new HashMap(); + 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(); + } + +}