Listing shows the inner class Node with set and get methods. Revise the class LinkedBag so that it invokes these set and get methods instead of accessing the private data fields data and next directly by name.
LISTING 1 The inner class Node with set and get methods
private class Node{ private T data; // entry in bag private Node next; // link to next node private Node(T dataPortion) { this(dataPortion, null); } // end constructor private Node(T dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } // end constructor private T getData() { return data; } // end getData private void setData(T newData) { data = newData; } // end setData private Node getNextNode() { return next; } // end getNextNode private void setNextNode(Node nextNode) { next = nextNode; } // end setNextNode} // end Node
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.