################################################################################
#                                                                              #
#                       Simulation of a Simple Market                          #
#                                                                              #
################################################################################

import random
import os.path

# The following function is useful and can be used as is;  there is no 
# reason to change it. 

def addCustomer( percent ):
    """This function returns True with a certain probability.  For
      example, if percent is 35, then this returns True 35% of the 
      times you call it and returns False 65% of the time. This is 
      a useful trick in a simulation. """
    return random.randint(0, 99) < percent

def generateEventsFile( N, perc, maxItems, fileName ):
    """Create a file of N lines to drive the simulation.  Each line in the
      file contains a single non-negative integer in range
      [0...maxItems].  Lines are non-zero perc percentage of the time.
      Use the function addCustomer( percent) to decide whether the
      item should be zero or a random integer between 1 and maxItems,
      inclusive.  The idea is that if a line is zero, no new customer
      has arrived during that clock tick.  Otherwise, a new customer
      has arrived at the cashier line with that many items in their
      basket.  Remember to close the file."""
    pass

def generateEventListFromFile( filename ):
    """Given a filename containing events, generate a list of the events
       suitable for the simulateCheckoutLine function.  Be sure to
       check that the file exists and print an error message and exit
       if not."""
    pass

############################## Customer Class ############################## 

class Customer:

    def __init__(self, custNum, itemCount):
        """A new customer is assigned a customer number and also a number of
        items in their basket.
        """
        pass

    def getCustomerNumber(self):
        """Getter for the customer's number."""
        pass

    def getItemsCount(self):
        """Getter for the customer's current count of items."""
        pass

    def decrementItemsCount(self):
        """Ring up (remove) one item from this customer's basket. 
        Typically, we'll only call this on the first customer in line."""
        pass

    def customerFinished(self):
        """Boolean function indicating that this customer will depart on 
        the current tick, i.e., there are zero items in their basket.  
        Typically we'll only call this on the first customer in line."""
        pass

    def __str__(self):
        """If this is customer n with k items in basket,
        return 'Cn(k)' """
        pass

############################## CheckoutLine Class ############################## 

class CheckoutLine:
    """A checkout line is implemented as a list with customers added at the front
    (L[0]) and removed from the rear (L[-1]).  Customers enter and
    move through the line.  At each tick, one item is removed from the
    basket of the first customer in line.  When their basket becomes
    empty, the first customer departs the line."""

    def __init__(self):
        """ Open a new line, with no customers initially. """
        pass
    
    def __len__(self):
        """Return the current length of the line."""
        pass

    def firstInLine(self):
        """ Return the first customer in the line."""
        pass

    def customerJoinsLine(self, cust):
        """ Add a new customer at the rear of the line.  Print a
            message indicating that the customer joined. """
        pass
        
    def customerLeavesLine(self):
        """ The first customer in line departs.  Remove the customer
            from the line and print a message. """
        pass  

    def advanceLine( self ):
        """ If the line is empty, don't change anything.  Otherwise,
            remove one item from the basket of the first customer in
            line.  If their basket becomes empty, they leave the
            line. (Use the previous methods to implement this.)"""
        pass

    def __str__(self):
        """ Return a string that shows the current state of the line. """
        pass

############################## Driver for the Simulation ############################## 

# The following function takes a list of events (non-negative integers) and drives
# the simulation based on the items in this list. 

def simulateCheckoutLine( eventList ):

    """This is the driver program for this system.  We monitor the
        progress of customers in the checkout line.  The eventList
        decides when a new customer is added with how many items in
        their cart. Customers are numbered as they enter. At each tick
        of the simulator clock (each new item in eventList), the
        cashier processes one item in the basket of the first
        customer."""
    pass

# You could write a main function to drive the simulation;  if so, comment it out before you
# submit.


# main()
