Homework Clinic

Science Clinic => Computer Science => Programming and Graphic Design => Topic started by: cdr_15 on Aug 30, 2020

Title: The textbook implemented a BookList class that had a BookNode defined as a nested inner class. That ...
Post by: cdr_15 on Aug 30, 2020
The textbook implemented a BookList class that had a BookNode defined as a nested inner class.  That is, the linked list, which itself had operations to add a Book to the list, or to traverse and print out the list, used a BookNode class, but the BookNode class was defined inside of BookList rather than imported.  With this in mind, answer the questions below.


What changes would have to be made to the BookNode class in order to define it as its own class outside of BookList?
Title: The textbook implemented a BookList class that had a BookNode defined as a nested inner class. That ...
Post by: macagnavarro on Aug 30, 2020
The BookNode class is defined as a private class with public instance data.  If BookNode is defined as its own class to be imported, then it must be defined as a public class and to preserve information hiding, the instance data should be defined as private.  Once the instance data are defined as private, methods are required to access and manipulate the instance data, so methods to set and return the two instance data need to be added.  These new methods might be called setBook, setNext, returnBook and returnNext.