subject

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); } }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:10
Dean wants a quick way to look up staff members by their staff id. in cell q3, nest the existing vlookup function in an iferror function. if the vlookup function returns an error result, the text “invalid staff id” should be displayed by the formula. (hint: you can test that this formula is working by changing the value in cell q2 to 0, but remember to set the value of cell q2 back to 1036 when the testing is complete.)
Answers: 3
question
Computers and Technology, 22.06.2019 14:50
Drag each label to the correct location on the image list the do’s and don’ts of safeguarding your password. a. keep yourself logged in when you leave your computer.b. don’t write your password down and leave it where others can find it.c. share your password with your friends.d.each time you visit a website,retain the cookies on your computer.e. use a long password with mixed characters.1. do's 2. don'ts
Answers: 2
question
Computers and Technology, 23.06.2019 03:00
Jason, samantha, ravi, sheila, and ankit are preparing for an upcoming marathon. each day of the week, they run a certain number of miles and write them into a notebook. at the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. write a program to them analyze their data. your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (you may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1 milesday2 milesday3 milesday4 milesday5 milesday6 milesday7.)
Answers: 3
question
Computers and Technology, 23.06.2019 14:00
Need ! will choose brainliest! discuss the role of abstraction in the history of computer software.
Answers: 1
You know the right answer?
Add a new method to the Point class and change the attributes (x, y) to private from the above quest...
Questions
question
Mathematics, 07.06.2021 18:50
question
Mathematics, 07.06.2021 18:50
Questions on the website: 13722359