From db80b906da7fbe4239416e758bae485ca3c0acfa Mon Sep 17 00:00:00 2001 From: Sara Kowalska Date: Sun, 5 Apr 2020 19:28:01 +0200 Subject: [PATCH] =?UTF-8?q?Pobieranie=20da=C5=84=20z=20kuchni=20i=20rozdaw?= =?UTF-8?q?anie=20ich=20klientom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Restaurant/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Restaurant/main.py b/Restaurant/main.py index 22b2d14..13f843e 100644 --- a/Restaurant/main.py +++ b/Restaurant/main.py @@ -20,6 +20,7 @@ class Plate(object): self.isEmpty = False self.preparationTime = dish.preparationTime self.eatingTime = dish.eatingTime + self.price = dish.price def eat(self): time.sleep(self.eatingTime) @@ -37,6 +38,13 @@ class Kitchen(object): time.sleep(plate.preparationTime) #kuchnia przygotowuje danie przez określony czas self.readyDishes.put(plate) + def giveDish(self): + if not self.readyDishes.empty(): + plate = self.readyDishes.get() + return plate + else: + return None + class Client(object): def __init__(self, age, sex, budget): @@ -148,6 +156,18 @@ class Waiter(object): def resetPosition(self, pos): self.pos = pos + def takePlates(self, kitchen): + for i in range(2): + plate = kitchen.giveDish() + if plate == None: + break + else: + self.plates.append(plate) + + def giveClientPlate(self, client): + plate = self.plates.pop(0) + client.takePlateAndEat(plate) + def draw(self, surface): i = self.pos[0] j = self.pos[1]