The array line in
POSline is now replaced by a singly linked
list of
CartNode objects.
The class
CartNode has been defined as follows.
class CartNode {
private Cart myCart;
private CartNode next;
public CartNode(Cart aCart) {
this.myCart = aCart;
this.next = null;
}
public Cart getCart() {
return this.myCart;
}
public CartNode getNext() {
return this.next;
}
public void setNext(CartNode nextNode) {
this.next = nextNode;
}
}
The class
POSlist has been implemented with the standard list methods
addLast and
removeFirst that act on
list.
Using object references, construct the method
public Cart removeFirst() that removes the first
CartNode object from
list. The method must return the
Cart object in that node or
null if
list is empty.