From 1f73504d78414e46ee2e2f80e343f862ae6f0419 Mon Sep 17 00:00:00 2001 From: trochas Date: Thu, 28 Nov 2024 10:37:38 +0100 Subject: [PATCH] compartiment fonction servir(), remplir() et getQuatite() --- src/Compartiment.java | 22 ++++++++++++++++++++-- src/Restaurant.java | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Compartiment.java b/src/Compartiment.java index e196be4..a3a4e11 100644 --- a/src/Compartiment.java +++ b/src/Compartiment.java @@ -1,3 +1,21 @@ -public class Compartiment { - +public class Compartiment{ + protected final int QUANTITE_MAX = 1000; + private int quantite_courant = 0; + + synchronized void remplir(){ + quantite_courant = QUANTITE_MAX; + } + + synchronized void servir(int qte){ + if(qte>quantite_courant){ + + } + else{ + quantite_courant -= qte; + } + } + + public int getQuantite(){ + return quantite_courant; + } } diff --git a/src/Restaurant.java b/src/Restaurant.java index 24a33c5..dd9feac 100644 --- a/src/Restaurant.java +++ b/src/Restaurant.java @@ -1,3 +1,4 @@ public class Restaurant { protected final int MAX_CLIENTS = 25; + private int nbClient = 0; } \ No newline at end of file