Java
Write a class called YourFirstNameLine that represents a line segment between two Points. Your
Line objects should have the following methods:
-
public YourFirstNameLine (Point p1, Point P2): construct a new Line that contains the
given two Points
-
public Point getStartPoint(): return this Line’s first endpoint
-
public Point getEndPoint(): return this Line’s second endpoint
-
public String toString(): return a String representation of this Line, such as “[(2,3), (4,7)]”
-
public double getSlope(): return 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 x2 equals x1, the denominator is zero
and the slope is undefined, so you may return a zero in this case
-
public void draw (Graphics g): draw a line in a DrawingPanel.
Write a client class called YourFirstNameLineTest with main method to test your Line class. In
the main method, you need create a line object with the last four numbers of your Panther ID.
For example, if your pantherid ends with xxxxx1234, then create and draw a line of between
point (1,2) and point (3,4). (Hint: you will need the Point.java, DrawingPanel.java,
YourFirstNameLine.java and YourFirstNameLineTest.java