Object Construction
Essentially, in java we were assigned to write a class called Line that represents a line segment.
To construct this two constructors must be used, one that accepts four different ints and the other that accepts two points that were formed from the firstconstructor.
The following methods are an example of something how the code should look.
public Line(Point p1, Point p2){// 1st constructor}
public Point getP1(){// Returns the Line’s first endPoint}
public Point getP2(){// Returns the Line’s second endPoint}
public String toString(){// Returns a String representation of this Line, such as “[(12, 2), (3, 6)]”.}
public double getSlope(){// Returns the slope of the line between the points labeled as (x1,y1), (x2,y2).}
public Line (int x1, int y1, int x2, int y2){// Second constructor.}
On top of this it is also important to import java.awt.*, so the Point class will act correctly.
Thanks for the help…
if(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-homeworklib_com-box-3-0’)};
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..
