Computers and Technology

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)]".

B) Add the following accessor method to your Line class:
public double getSlope()

Returns the slope of this Line. The slope of a line between points (x1, y1) and (x2, y2) is equal to (y2 – y1) / (x2 – x1). If x2equalsx1 the denominator is zero and the slope is undefined, so you may throw an exception in this case.

C) Add the following constructor to your Line class:
public Line(int x1, int y1, int x2, int y2)

Constructs a new Line that contains the given two Points.

D) Add the following accessor method to your Line class:
public boolean isCollinear(Point p)

Returns true if the given Point is collinear with the Points of this Line —that is, if, when this Line is stretched infinitely, it would eventually hit the given Point

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:30, mesposito
Technician a says that a dry sump system uses no oil storage sump under the engine. technician b says that a wet sump system uses no oil storage sump under the engine. who is correct?
Answers: 3
image
Computers and Technology, 23.06.2019 00:30, devenybates
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
image
Computers and Technology, 23.06.2019 11:00, jolleyrancher78
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, AM28
Does read theory have answers keys ?
Answers: 1
Do you know the correct answer?
Write a class called Line that represents a line segment between two Points. Your Line objects shoul...

Questions in other subjects: