Question: Please code in java, thanks Here is Point p class Points { private double px; private double py; public Points(double px, double py) { this.px
Please code in java, thanks



Here is Point p
class Points { private double px; private double py; public Points(double px, double py) { this.px = px; this.py = py; } public double getPx() { return px; } public void setPx(double px) { this.px = px; } public double getPy() { return py; } public void setPy(double py) { this.py = py; } @Override public String toString() { return "Points [" + "px=" + px + ", py=" + py + ']'; } }1 Define a Circle class as follows: Two double data fields named xpos and ypos that specify the center of the circle. A double data field radius. A constructor that creates a circle with the specified xpos, ypos and radius. Three Getter methods, one each for xpos, ypos and radius. Two Setter methods: one for setting the center and one for setting the radius A method contains(Point p) that returns true if a given Point is inside this Circle object. It should return true even if the point touches the Circle. Hints for contains (Point p): Consider the position of p relative to the position of the circle's center. If a point sits inside the circle, how far it can go? Let R be the radius of the circle and d be the Euclidean distance between the center of the circle (xpos, ypos) and the point p(a, b). Then d = (xpos - a)2 + (ypos - b)2 If d SR, p is contained in the circle; if d > R, p is not contained in the circle. Examples are shown below. 2 3 (0.0) 2.0 (2.21 2 R=2 R=d3 NO da? 4 Point is contained lolo Point is contained Point is not contained Then define a class called Demo2 that works as follows. It defines a circle different from the example given above and displays the data fields. Defines three points with the following properties, and displays the data field. A point p1 lies inside of the circle o A point p2 touches the side of the circle o A point p3 lies outside of the circle Calls contains(Point p) method, and this method must correctly identifies whether each one of these points is contained in the circle. Finally, provide the complete console output of the above three test cases (p1, p2, p3). A sample dialog and output is given below. . = Created one circle object: [xpos = 2, ypos = 2] radius 2 Created a point object: p1 [xpos 3, ypos 1] Created a point object: p2 [xpos = 2, ypos = 0] Created a point object: p3 [xpos 4, ypos = 4] Is p1 contained in the circle? true Is p2 contained in the circle? true Is p3 contained in the circle? false Marking rubric . 0.25 mark is deducted for missing one test case. . 0.25 mark is deducted for not displaying data fields
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
