CS

• Homework Help
• joeljoe222
• 2
• 100% (1) 1 out of 1 people found this document helpful

This preview shows pages 1–2. Sign up to view the full content.

WORKSHEET A29.1 LinkedList 1. The following program builds on Worksheet A15.1, ArrayList that uses an ArrayList to store and perform geometric calculations on a set of coordinate points – using the Point2D.Double class. In this problem, we will use a LinkedList instead of an ArrayList to store the points. This program uses ListNode.java and SinglyLinkedList.java from the lesson, as well as the class below. import java.awt.geom.*; // for Point2D.Double class MySinglyLinkedList extends SinglyLinkedList{ // assumes the first word in the first line from SinglyLinkedList is changed from // private to protected. // Note that this method overloads printList() from SinglyLinkedList public void printList(){ ListNode temp = getFirstNode();// start from the first node while (temp != null ){ System.out.println("(" + ((Point2D.Double)temp.getValue()).getX() + "," + ((Point2D.Double)temp.getValue()).getY() + ")"); temp = temp.getNext();// go to next node } } public double calculateArea(){ // assumes points received from user form a rectangle ListNode temp = getFirstNode();// start from the first node Point2D.Double ptD = (Point2D.Double)temp.getValue();

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Spring '17

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern