Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create two classes Node and PointList which will implement a list of (x,y) point

ID: 3677724 • Letter: C

Question

Create two classes Node and PointList which will implement a list of (x,y) points using a linked list.

1. A Node should have three private instance variables: two double values x and y, and a link to the next Node in the list. Provide a constructor which will initialize all three of these instance variables. Provide a Node getLink() method which will allow access to the link to the next Node in the list. You do not need any other get/set methods for the Bronze exercise.

2. Provide a String  toString() method in the Node class which will return a String showing the x and y values in the format "(0.343,0.982)" . Use the built-in method String.format("%5.3f",dataValue) to ensure that both the x and y values display exactly 3 decimal places.

3. A PointList should have a single private instance variable containing a reference to the first Node in the list (or null if there are none). Provide a constructor which will create an empty list. Provide a void  add(double x,  double y) method which will add the point (x,y) to this list of points, at the beginning. Provide the usual String   toString() method which will return a String showing all of the points in the list, in the following format: "[   (0.435,0.234) ( 0.123,0.876)    (0.321,0.789)    ]".

4. Run the supplied TestLab8Bronze.java program to test your classes. This program will generate and print a list of 5 random points.

Explanation / Answer

Please find the required code below :