package travaux; import java.util.ArrayList; public class Batiment { //------------------------------------------------------------------------- // PROPRIETES private String nom; private ArrayList listeSalles; //------------------------------------------------------------------------- // CONSTRUCTEURS public Batiment() { listeSalles = new ArrayList(); nom = "NC"; // non connu } public Batiment(String n) { listeSalles = new ArrayList(); nom = n; } //------------------------------------------------------------------------- // METHODES "INTELLIGENTES" public void afficherInfos() { System.out.println("Batiment :" + nom); System.out.print("Liste des salles : "); for (Salle s : listeSalles) { s.afficherInfos(); } } //------------------------------------------------------------------------- // METHODES D'ACCES public void ajouterSalle(Salle s) { if (s==null) throw(new IllegalArgumentException("La salle ne doit pas ĂȘtre 'null'.")); listeSalles.add(s); } public void supprimerSalle(Salle s) { listeSalles.remove(s); } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } }