package lepack; import java.util.ArrayList; public class Batiment { private String nom; private ArrayList listeSalles; public Batiment() { listeSalles = new ArrayList(); nom = "NC"; } public Batiment(String n) { listeSalles = new ArrayList(); nom = n; } public void afficherInfos() { System.out.println("Batiment :" + nom); System.out.print("Liste des salles : "); for (Salle s : listeSalles) { s.afficherInfos(); } } 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; } public ArrayList getListeSalles() { return this.listeSalles; } }