Question: Java homework Write a class named LineSegment. In geometry, a line segment is a piece of a line. It has two end points. Your LineSegment

Java homework

Write a class named LineSegment. In geometry, a line segment is a piece of a line. It has two end points. Your LineSegment class should model a line segment by storing two private Point member variables.

It should have the following constructors.

The first constructor accepts two Point references and and stores copies of those Points into member variables.

The second constructor takes a LineSegment as a parameter. It is a copy constructor.

LineSegment(Point p1, Point p2)

LineSegment(LineSegment segment)

It should have the following methods (note, no setters required):

public Point getP1()

pubic Point getP2()

public double length()

public boolean isLongerThan(LineSegment segment)

The length method should return the length of the segment. The distance between the end points

The isLongerThan method should accept a LineSegment, and return true if the receiving line segment is longer than the argument.

(Your answer to this question should be an entire class. Everything that would go into LineSegment.java)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!