Page 1 of 1

Exercise 4. Points and Lines PART A Creating a Point com. In this first part of this problemes required to create a new

Posted: Mon May 02, 2022 12:43 pm
by answerhappygod
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 1
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 1 (44.38 KiB) Viewed 37 times
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 2
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 2 (44.38 KiB) Viewed 37 times
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 3
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 3 (60.49 KiB) Viewed 37 times
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 4
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 4 (60.49 KiB) Viewed 37 times
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 5
Exercise 4 Points And Lines Part A Creating A Point Com In This First Part Of This Problemes Required To Create A New 5 (16.66 KiB) Viewed 37 times
Exercise 4. Points and Lines PART A Creating a Point com. In this first part of this problemes required to create a new cas called Pore. Apoints described by its geometric coordinates. In this problem, a two-dimensional cartesian coordinate system is considered. Consequently a point way, in such a system defined by sband ordinate y. Following the definition of a generic point's coordinates write accesser and mutator methods, namely). YO. XI ... Note that the production return both the abscesa and ordinate of a point. Also, the sexy two parameters as inputs being the news and new ordinate of the point. The bring done, we function called distance that takes a point object, say secondPoint, as a parameter and computes the cartesian distance between the current point and recordPort. Finally, a sorel) method will print out the and coordinates of a point is an appropriate PART : Creating a Line class. Here, its required to use the point dass in order to create a new line dass. Real a heart described by the two points, apland that goes through. It alio has an equition of the form yes were the slope and in the intercept. In addition, this problemen wil have one additional property beng the range over which can be plotted where it and are the lower and upper bounds delimiting this the nextpageancomplete skeleton of the dans Line which you are required to complete Description below 1. The constructor function takes two input Point parameters pl and p2 and constructa new line object. Throughout the construction, Diven the two points, the constructor will resort to Helper Function called computeEquation whose description is below. 2. The helper function computeEquation takes the newly constructed in ohjeitas a parameter and computes seation which it returns astringe to be stored in the warble of the line object Throughout the computation of the equation the computer functions pren the authority to mulate the respective slope and intercept variablessandro the object and store in them their corresponding values which computes using the coordinates of the points pl and p2 above. Here, note that geen two points Payal and 2x2y the slope and terest of the treating through them are sty2-y)/(x2-1) ry1 - 1 following the computation of sand above,pecial care due when creating the string rule egna professional manner, That and the String variable should contar where replaced by its value) Atematively and then the String vables should only contain 'wheres replaced by its value). In addition, thene should contain Yexelwhere is replaced by ts value The toString) method which retuma meaningful string containing all the information to the sewly created line. A sample output of the toString method once called using an appropriate print command from the client program a pon below is wel PART Driver/Client program In this part is required to create JAVA cient program called LineCentet the functionality of the above classes Samole output for the town function of the line de Point 121 Point 2014 En yux.
Exercise 4. Points and Lines PART A: Creating a Point class. In this first part of this problem, it is required to create a new class called Point. A point is typically described by its geometric coordinates. In this problem, a two-dimensional cartesian coordinate system is considered. Consequently, a point, sayP, in such a system is defined by its abscksax and ordinate y. Following the definition of a generic point's coordinates, write accessor and mutator methods, namely, getX().getY(), setX(), setY().getX(), setxYC). Note that the getX() function will return both the abscissa and ordinate of a point. Also, the setX() takes two parameters as inputs being the new abscissa and new ordinate of the point. This being done, write a function called distance() that takes a point object, say secondPoint, as a parameter and computes the cartesian distance between the current point and secondPoint. Finally, a toStringi) method wil print out the x and y coordinates of a point in an appropriate string. PART B: Creating a Line class. Here, it is required to use the Point class in order to create a new Line class. Recall, a Line, says described by the two points, say pl and p2that it goes through. It also has an equation of the form y = 5x+ where is the slope and is the intercept. In addition, in this problem, a line will also have one additional property being the range (xlrulover which it can be plotted where xl and xu are the lower and upper bounds delimiting this range. On the next page is an incomplete skeleton of the class Line which you are required to complete Description is below: 1. The constructor function takes two input Point parameters p1 and p2 and constructs a new Line object. Throughout the construction, given the two points, the constructor will resort to a Helper Function called computeEquation whose description is below. 2. The helper function computeEquation takes the newly constructed Line object as a parameter and computes its equation which it returns as a String eq to be stored in the variable e of the line object. Throughout the computation of the equation, the computeEquation) function is given the authority to mutate the respective slope and intercept variables sandi of the object and store in them their corresponding values which it computes using the coordinates of the points pl and p2 above. Here, note that given two points P1x1, y1) and P2[x2, y2), the slope and intercept of the line passing through them are: $+(y2- y1)/(x2-x1); i = y1 - 5-11 Following the computation of sand above, special care is due when creating the String variable eq in a professional manner. That is, if s= 0 and i=0 the String variable eq should contain 'y=1 (wherei is replaced by its value). Aternatively, its and then the String variable eq should only contain Y=sx(wheres is replaced by its value). In addition, its = 1, then eq should contain Y=x+1(where his replaced by its value) 3. The toString() method which return a meaningful string containing all the information about the newly created line. A sample output of the toString method once called using an appropriate print) command from the client program is given below as well.
PART C: Driver / Client program. In this part it is required to create a JAVA client program called Line Client.java to test the functionality of the above classes. Sample output for the toString() function of the Line class: Point 1: (1, 2) Point 2: (3, 4) Equation: y = x + 1