Skip to content

Instantly share code, notes, and snippets.

@adpoe
Created March 14, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adpoe/a337ac8e9b455dbdb687 to your computer and use it in GitHub Desktop.
Save adpoe/a337ac8e9b455dbdb687 to your computer and use it in GitHub Desktop.
A Queue Class for Python Simulation
##########################
#### 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