Files
first-depot/travaux/Batiment.java
2025-10-07 16:46:34 +02:00

60 lines
1.2 KiB
Java

package travaux;
import java.util.ArrayList;
public class Batiment {
//-------------------------------------------------------------------------
// PROPRIETES
private String nom;
private ArrayList<Salle> listeSalles;
//-------------------------------------------------------------------------
// CONSTRUCTEURS
public Batiment() {
listeSalles = new ArrayList<Salle>();
nom = "NC"; // non connu
}
public Batiment(String n) {
listeSalles = new ArrayList<Salle>();
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;
}
}