|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object CheckoutLane
public class CheckoutLane
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 |
---|
public CheckoutLane(int initialSize)
initialSize
- the initial size of the lane array.Method Detail |
---|
public int getCustomerCount()
public void addCustomer(Customer c)
c
- a Customerpublic void insertCustomer(Customer c, int pos)
c
- a Customerpos
- the position to add the Customerpublic Customer getFirstCustomer()
public Customer getCustomerAt(int pos)
pos
- the position in the lane to inspect
public Customer removeFirstCustomer()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |