Created
March 14, 2016 03:04
-
-
Save adpoe/a337ac8e9b455dbdb687 to your computer and use it in GitHub Desktop.
A Queue Class for Python Simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################## | |
#### CHECK-IN QUEUES ##### | |
########################## | |
class CheckInQueue: | |
""" Class used to model a check-in line Queue | |
""" | |
def __init__(self): | |
self.queue = q.Queue() | |
self.customers_added = 0 | |
def add_passenger(self, new_passenger): | |
self.queue.put_nowait(new_passenger) | |
self.customers_added += 1 | |
def get_next_passenger_in_line(self): | |
if not self.queue.empty(): | |
next_customer = self.queue.get_nowait() | |
self.queue.task_done() | |
else: | |
next_customer = None | |
return next_customer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment