Menu

[Solved] Part 1 Basic Class Structure Create Class Called Node Private String Variable Called Value Q37254194

Part 1. Basic class structure

Create a class called Node. It should have a private Stringvariable called ‘value’. Give the Node class another privatevariable with type Node called ‘nextNode’. This means that yourNode class will have a Node reference variable.

Implement getter and setter methods for the Node class members.Implement a constructor that has a String parameter, and sets the‘value’ variable to the parameter and the ‘nextNode’ variable tonull. Implement a second constructor that takes both String andNode parameters and sets the class variables to the parameters.

Create a class called List. It should have a private Nodevariable called ‘start’. Implement getter and setter methods forthe variable. Implement a constructor that takes a Node parameterand sets the ‘start’ variable to the parameter.

Part 2. Add to a List.

In the List class, create and implement a method public voidaddToEndOfList(Node n)that will add the parameter to the end of thelist.

This method should start at the ‘start’ Node variable, and loopthrough until it reaches the last Node in the list. Then set thelast Node’s ‘nextNode’ variable to the parameter of addToList. Youcannot use the ListIterator class for this – you will need to loopthrough the list manually.

Expert Answer


Answer to Part 1. Basic class structure Create a class called Node. It should have a private String variable called ‘value’. G… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *