Dodanie klas kuchni i klienta, użycie kolejki (import)
This commit is contained in:
parent
81a86d7657
commit
1bbdbb3602
@ -1,23 +1,54 @@
|
||||
import pygame
|
||||
import random
|
||||
import time
|
||||
import queue
|
||||
|
||||
pygame.init()
|
||||
|
||||
|
||||
class Dish(object):
|
||||
def __init__(self, dishName, prepTime):
|
||||
def __init__(self, dishName, prepTime, eatTime):
|
||||
self.dishName = dishName
|
||||
self.preparationTime = prepTime
|
||||
self.eatingTime = eatTime
|
||||
|
||||
|
||||
class Plate(object):
|
||||
def __init__(self, dish):
|
||||
self.dishName = dish.dishName
|
||||
self.isEmpty = False
|
||||
self.preparationTime = dish.preparationTime
|
||||
self.eatingTime = dish.eatingTime
|
||||
|
||||
def eat(self):
|
||||
time.sleep(self.eatingTime)
|
||||
self.isEmpty = True #zjadanie dania jest oznaczeniem talerza jako pusty (metoda będzie wywoływana przez klienta)
|
||||
|
||||
|
||||
class Kitchen(object):
|
||||
def __init__(self):
|
||||
self.readyDishes = queue.queue(32) #kolejka o maksymalnej długości 32
|
||||
self.orders = queue.queue(32)
|
||||
|
||||
def makeDish(self):
|
||||
if not self.orders.empty():
|
||||
plate = self.orders.get()
|
||||
time.sleep(plate.preparationTime) #kuchnia przygotowuje danie przez określony czas
|
||||
self.readyDishes.put(plate)
|
||||
|
||||
|
||||
class Client(object):
|
||||
def __init__(self, age, sex, budget):
|
||||
self.age = age
|
||||
self.sex = sex
|
||||
self.myPlate = None
|
||||
self.budget = budget
|
||||
|
||||
def takePlateAndEat(self, plate):
|
||||
self.myPlate = plate
|
||||
plate.eat()
|
||||
|
||||
|
||||
class Table(object):
|
||||
def __init__(self, pos):
|
||||
self.pos = pos
|
||||
@ -42,7 +73,7 @@ class Waiter(object):
|
||||
self.pos = pos #pozycja agenta, zapisana w formie dwuelementowej listy
|
||||
self.dirnx = 0 #zmienne dirnx i dirny używane są do ruchu bota i ustalania, w którą stronę jest zwrócony
|
||||
self.dirny = 1
|
||||
self.plates = {} #lista niesionych przez agenta talerzy
|
||||
self.plates = {} #lista niesionych przez agenta talerzy, planowo lista par: (talerz, klient)
|
||||
|
||||
def moveRandomly(self):
|
||||
rand = random.randrange(1, 5, 1) #losuje w zakresie 1-4
|
||||
@ -57,7 +88,7 @@ class Waiter(object):
|
||||
elif rand == 2:
|
||||
self.dirnx = 1
|
||||
self.dirny = 0
|
||||
if self.pos[0] == 15:
|
||||
if self.pos[0] == 14:
|
||||
self.dirnx *= (-1)
|
||||
self.pos = (self.pos[0] + self.dirnx, self.pos[1] + self.dirny)
|
||||
elif rand == 3:
|
||||
@ -69,7 +100,7 @@ class Waiter(object):
|
||||
elif rand == 4:
|
||||
self.dirnx = 0
|
||||
self.dirny = 1
|
||||
if self.pos[1] == 15:
|
||||
if self.pos[1] == 14:
|
||||
self.dirny *= (-1)
|
||||
self.pos = (self.pos[0] + self.dirnx, self.pos[1] + self.dirny)
|
||||
|
||||
@ -109,7 +140,7 @@ class Waiter(object):
|
||||
self.pos = (self.pos[0] + self.dirnx, self.pos[1] + self.dirny)
|
||||
break
|
||||
|
||||
def reset(self, pos):
|
||||
def resetPosition(self, pos):
|
||||
self.pos = pos
|
||||
|
||||
def draw(self, surface):
|
||||
|
Loading…
Reference in New Issue
Block a user