Computers and Technology

Add a new method to the Point class and change the attributes (x, y) to private from the above question: public double distance(Point next) This method returns the distance between the current Point object and the next Point object in the parameter. The distance between two points is the square root of the sum of the square of the differences of the x and y coordinates: square root of ( (x2 – x1)2 + (y2 – y1)2 ). (6 points) In the Point class, add private to int x and int y. You will have to modify the RefereceX. java and Point. java to deal with this change of modifier from the public to private. (6 points) Based the question 4 codes with the above additions, you should have the following results ( 3 points to display results) inside addTox(..): 14 14 7 9 14 3 inside addTox(..): 18 18 7 9 14 18 distance of p1 from origin is 14.142135623730951 distance of p2 from origin is 18.439088914585774 distance between p1 and p2 is = 4.47213595499958 Code: public class Point { int x; int y; // Constructs a new point with the given (x, y) location. // pre: initialX >= 0 && initialY >= 0 public Point(int initialX, int initialY) { this. x = initialX; this. y = initialY; } // Returns the distance between this point and (0, 0). public double distanceFromOrigin() { return Math. sqrt(x * x + y * y); } // Shifts this point's location by the given amount. // pre: x + dx >= 0 && y + dy >= 0 public void translate(int dx, int dy) { this. x += dx; this. y += dy; } public double distance(Point next) { //help } } public class ReferenceX { public static void main(String[] args) { int x = 7; int y = 9; Point p1 = new Point(1, 2); Point p2 = new Point(3, 4); addToX(x, p1); System. out. println(x + " " + y + " " + p1.x + " " + p2.x); addToX(y, p2); System. out. println(x + " " + y + " " + p1.x + " " + p2.x); } public static void addToX(int x, Point p1) { x += x; p1.x = x; System. out. println(" inside addTox(..): " + x + " " + p1.x); } }

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:10, erick7123
The head restraint should be adjusted so that it reaches a. the top of your ears b. the base of your skull c. the top of the head
Answers: 1
image
Computers and Technology, 24.06.2019 07:20, djs1002
Ingrid started speaking about her slide presentation. when she clicked to th"third slide, which had just a picture of an elephant, she forgot what she wassupposed to talk about. what could ingrid do to avoid this situation in thefuture? oa. print handouts for her audience. ob. add presenter's notes to each slide. oc. add a video to each slide. od. save her slide presentation to a flash drive
Answers: 2
image
Computers and Technology, 24.06.2019 17:40, orlandokojoasem1234
Write an assembly language program to input a string from the user. your program should do these two things: 1. count and display the number of words in the user input string. 2. flip the case of each character from upper to lower or lower to upper. for example if the user types in: "hello there. how are you? " your output should be: the number of words in the input string is: 5 the output string is : hello there. how are you?
Answers: 2
image
Computers and Technology, 24.06.2019 18:20, 12375819
Use a while-end loop in a script file to calculate the sum of the first n terms of the series: summation sign on the top n bottom k=1 : )^k * k^2 +5k)/3^k show the script file and the two results of n = 10 and n = 20.
Answers: 2
Do you know the correct answer?
Add a new method to the Point class and change the attributes (x, y) to private from the above quest...

Questions in other subjects:

Konu
Geography, 16.06.2020 03:57
Konu
Mathematics, 16.06.2020 03:57
Konu
Mathematics, 16.06.2020 03:57
Konu
Mathematics, 16.06.2020 03:57