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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started