diff --git a/Au_Woke.java b/Au_Woke.java new file mode 100644 index 0000000..9da0029 --- /dev/null +++ b/Au_Woke.java @@ -0,0 +1,16 @@ +public class Au_Woke { + private Client[] clients= new Client[30]; + private Restaurant restaurant =new Restaurant(); + Au_Woke(){ + restaurant.cuisinier.start(); + restaurant.employeB.start(); + for(int i=0; i compartiment.getQuantite()){ - this.wait(); + compartiment.wait(); } } catch (InterruptedException e){ e.printStackTrace(); @@ -46,7 +46,7 @@ public class Client extends Thread { synchronized(restaurant){ try{ while(!restaurant.libre()){ - this.wait(); + restaurant.wait(); } restaurant.ajouterClient(); restaurant.notifyAll(); diff --git a/src/Compartiment.java b/src/Compartiment.java index 42ebfab..d982f16 100644 --- a/src/Compartiment.java +++ b/src/Compartiment.java @@ -3,7 +3,7 @@ public class Compartiment{ private int quantite_courant; Compartiment(){ - quantite_courant = 0; + quantite_courant = 500; } synchronized void remplir(){ diff --git a/src/Restaurant.java b/src/Restaurant.java index 2da49bd..9091122 100644 --- a/src/Restaurant.java +++ b/src/Restaurant.java @@ -1,11 +1,13 @@ public class Restaurant { protected final int MAX_CLIENTS = 25; - private int nbClient; + + public int nbClient; public Compartiment[] buffet = new Compartiment[4]; - private Employe_du_buffet employeB; + public Employe_du_buffet employeB; public Stand_de_cuisson stand_de_cuisson; - private Cuisinier cuisinier; + public Cuisinier cuisinier; + /* private Client[] clients= new Client[MAX_CLIENTS+5]; Restaurant(){ @@ -25,8 +27,17 @@ public class Restaurant { } } + */ + public Restaurant(){ + this.nbClient=0; + for(int i = 0 ; iMAX_CLIENTS){ return false; @@ -45,7 +56,5 @@ public class Restaurant { nbClient--; } } - public static void main(String[] args){ - new Restaurant(); - } + } \ No newline at end of file