Files
tp-4-wok/src/Restaurant.java
2024-12-02 16:30:52 +01:00

43 lines
1.0 KiB
Java

public class Restaurant {
protected final int MAX_CLIENTS = 25;
private int nbClient;
public Compartiment[] buffet = new Compartiment[4];
private Employe_du_buffet employeB;
public Stand_de_cuisson stand_de_cuisson;
private Cuisinier cuisinier;
Restaurant(){
nbClient = 0;
for(int i = 0 ; i<buffet.length; i++){
this.buffet[i] = new Compartiment();
}
this.employeB = new Employe_du_buffet(buffet);
this.stand_de_cuisson = new Stand_de_cuisson();
this.cuisinier = new Cuisinier(stand_de_cuisson);
employeB.run();
cuisinier.run();
}
public synchronized boolean libre(){
if(nbClient>MAX_CLIENTS){
return false;
}else {
return true;
}
}
public synchronized void ajouterClient(){
if(nbClient<MAX_CLIENTS){
nbClient++;
}
}
public synchronized void diminuerClient(){
if(nbClient>MAX_CLIENTS){
nbClient--;
}
}
}