Class CheckoutLane

java.lang.Object
  extended by CheckoutLane

public class CheckoutLane
extends java.lang.Object

The CheckoutLane class models a checkout lane, with a line of customers waiting to be served. Your implementation of the Lane class will use a ResizableArray to keep track of customers. Note that the get method of ResizableArray returns an Object; you will have to cast it to a Customer as follows: Customer c = (Customer)(ra.get(0)); Note also that many of the requirements placed upon methods in CheckoutLane are taken care of by ResizableArray.


Constructor Summary
CheckoutLane(int initialSize)
          Constructs a Lane with an underlying array of the given initial size.
 
Method Summary
 void addCustomer(Customer c)
          Adds the specified customer to the end of this lane's line.
 Customer getCustomerAt(int pos)
          Returns the customer at the given position in this lane.
 int getCustomerCount()
          Returns the number of customers currently in this Lane.
 Customer getFirstCustomer()
          Returns the customer at the head of this lane.
 void insertCustomer(Customer c, int pos)
          Adds the specified customer ahead of the customer at the specified position.
 Customer removeFirstCustomer()
          Removes the first customer from this lane, decrements the current customer count, and shifts all other customers one element towards the head of the lane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckoutLane

public CheckoutLane(int initialSize)
Constructs a Lane with an underlying array of the given initial size.

Parameters:
initialSize - the initial size of the lane array.
Method Detail

getCustomerCount

public int getCustomerCount()
Returns the number of customers currently in this Lane.

Returns:
the number of customers currently in this Lane

addCustomer

public void addCustomer(Customer c)
Adds the specified customer to the end of this lane's line.

Parameters:
c - a Customer

insertCustomer

public void insertCustomer(Customer c,
                           int pos)
Adds the specified customer ahead of the customer at the specified position.

Parameters:
c - a Customer
pos - the position to add the Customer

getFirstCustomer

public Customer getFirstCustomer()
Returns the customer at the head of this lane.

Returns:
the first customer in this lane

getCustomerAt

public Customer getCustomerAt(int pos)
Returns the customer at the given position in this lane.

Parameters:
pos - the position in the lane to inspect
Returns:
the first customer in this lane

removeFirstCustomer

public Customer removeFirstCustomer()
Removes the first customer from this lane, decrements the current customer count, and shifts all other customers one element towards the head of the lane.

Returns:
the Customer formerly at the front of this lane