Problem

Listing shows the inner class Node with set and get methods. Revise the class LinkedBag so...

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

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 3
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT