Олимпиадный тренинг

Задача . 17-b


Задача

Темы:

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.

time 500 ms
memory 256 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
 Кол-во
Java8
Комментарий учителя