subject

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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 24.06.2019 17:30
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 2
question
Computers and Technology, 25.06.2019 01:00
Holly created a professional development plan to explore how she could advance from her entry-level position to the next step in her career. she has identified her current skills and the skills needed for the job she wants. what should she do now? a) ask a colleague for advice about work-life balance b) identify her areas for improvement c) plan a vacation before she begins her new job d) wait until a position opens before continuing her plan
Answers: 1
You know the right answer?
Write a class called Line that represents a line segment between two Points. Your Line objects shoul...
Questions
question
Advanced Placement (AP), 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
question
History, 16.10.2020 18:01
question
Arts, 16.10.2020 18:01
question
History, 16.10.2020 18:01
Questions on the website: 13722360