



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Out: 2/ Due: 3/9 by 11:50 PM
In this project you will implement a class to model a line segment.
One beauty of an object oriented language is that it allows a programmer to employ abstraction in representing real world objects, including geometric shapes. In this project you will implement a class that models a line segment. You will then use objects of the class to create a the sides of a triangle and calculate the area and perimeter of the triangle. A triangle is defined by three line segments which are in turn defined by three pairs of x- and y- coordinates. You will compute the perimeter and the area of the triangle. You will than modify the line segments to form a new triangle and again compute the perimeter and area of the new triangle.
Read API documentation for the LineSegment class that I have on Moodle. Specifically, read the field, method, and constructor summaries and details. You will implement the LineSegment class.
Write a client class to test your implementation of the LineSegment class that you implemented.
(a) Move the end point of first line segment 5 pixels right-ward and 10 pixels downward. (b) Move the start point of the second line segment 5 pixels right-ward and 10 pixels downward. (c) Move the end point of the second line segment 5 pixels left-ward and 10 pixels downward.
A typical program interaction would be:
Sample Run:
Enter the x- and y- coordinates of the first point> 60 60 Enter the x- and y- coordinates of the second point> 100 100 Enter the x- and y- coordinates of the third point> 20 100
The sides of the triangle are line 1:[(60.0,60.0)->(100.0,100.0)] line 2:[(100.0,100.0)->(20.0,100.0)] line 3:[(20.0,100.0)->(60.0,60.0)]
Perimeter = 193. Area = 1600.
The sides of the triangle are line 1:[(60.0,60.0)->(105.0,110.0)] line 2:[(105.0,110.0)->(15.0,110.0)] line 3:[(15.0,110.0)->(60.0,60.0)]
Perimeter = 224. Area = 2249.
Compile your two Java source files (LineSegment.java and LineSegmentTester.java) until they are free of any syntax and/or semantic errors. Once you are satis- fied that your program properly compiles and is syntax and semantic error- free, submit your work. You may submit your work as many times as you wish once the due time has not elapsed. After the due time, any further submission will mean that you get no points for the project. Your program will be graded for both proper style and syntax.
/**