Ashy A.

asked • 02/21/21

comp sci question

Write a class called Line that represents a line segment between two Points. Your Line objects should have the following methods:


public Line(Point p1, Point p2)

Constructs a new line that contains the given two points.


public Point getP1()

Returns this line's first endpoint.


public Point getP2()

Returns this line's second endpoint.


public String toString()

Returns a string representation of this line, such as "[(22, 3), (4, 7)]".

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.