Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions