of ol e @0verride public String toString(){ SYOUR CODE HERE> public static void main(String[] args) { /* create point p = (2,3) using keyword new */ SYOUR CODE HERE> System.out.println("p=" + p); /* create point q using p.getLocation() */ System.out.println("q="+q); /* translate q up 3 and left 1 */ System.out.println("q="+q); /* make q refer to p */ System.out.println("q="+q);
of ol e @0verride public String toString(){ SYOUR CODE HERE> public static void main(String[] args) { /* create point p = (2,3) using keyword new */ SYOUR CODE HERE> System.out.println("p=" + p); /* create point q using p.getLocation() */ System.out.println("q="+q); /* translate q up 3 and left 1 */ System.out.println("q="+q); /* make q refer to p */ System.out.println("q="+q);
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question

Transcribed Image Text:import java.util.Objects;
public class Point {
protected double x, y;
/*
Instantiates an x and y value based on its input
3 ol
7
Point class:
input:
double x: x position
double y: y position
9.
10
11
*/
public Point(double x, double y) { this.x =x; this.y = y;}
/*
12
13
14
"Getter": returns
position
output:
double: x position
15
16
17
*/
public double getX() { return x; }
/*
"Getter": returns y position
18
19
20
21
output:
22
double: y position
23
*/
public double getY() { return y; }
/*
returns a new point at its current location
24
25
26
27
output:
28
Point: a new point at current points location
29
*/
public Point getLocation() { return new Point(x, y); }
/*
update the position of the current point
input:
double x: new x position
double y: new y position
30
31
32
33
34
35
36
*/
public void setlLocation(double x, double y) { this.x = x; this.y = y; }
/*
moves the point to a new position
input:
37
38
39
40
41
double dx: how much to move the x coordinate
double dy: how much to move the y coordinate
42
43
*/
public void translate(double dx, double dy) { x +=dx; y += dy;}
/*
checks if this point and another point are the same
44
45
46
47
output:
48
boolean: if the points are the same
49
![50 O이 습
@0verride public boolean equals(Object object) {
if (object instanceof Point ){
Point point = (Point)object;
51
52
53
return (x
point.x) && (y == point.y);
==
54
55
else
56
return false;
57
}
58 O이
@0verride public int hashCode () { return Objects.hash(x,y); }
61
62
/*
63
tostring: default string format for this class
64
output:
65
String: (x,y) (no spaces)
66
67 O이
@0verride public String tostring(){
<YOUR CODE HERE>
}
public static void main(String[] args) {
/* create point p = (2,3) using keyword new */
<YOUR CODE HERE>
System.out.println("p=" + p);
68
69
70
71
72
73
74
/* create point q using p.getLocation() */
<YOUR CODE HERE>
System.out.println("q="+q);
75
76
77
78
79
/* translate q up 3 and left 1 */
80
<YOUR CODE HERE>
81
System.out.println("q="+q);
82
/* make q refer to p */
<YOUR CODE HERE>
System.out.println("q="+q);
83
84
85
86
87
88
}
89
D-D-](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbeaaa11f-b4ba-46f9-b461-ce84893e9827%2F4546e65d-0586-4d05-951c-d3083a84d58e%2Fr73uedb_processed.png&w=3840&q=75)
Transcribed Image Text:50 O이 습
@0verride public boolean equals(Object object) {
if (object instanceof Point ){
Point point = (Point)object;
51
52
53
return (x
point.x) && (y == point.y);
==
54
55
else
56
return false;
57
}
58 O이
@0verride public int hashCode () { return Objects.hash(x,y); }
61
62
/*
63
tostring: default string format for this class
64
output:
65
String: (x,y) (no spaces)
66
67 O이
@0verride public String tostring(){
<YOUR CODE HERE>
}
public static void main(String[] args) {
/* create point p = (2,3) using keyword new */
<YOUR CODE HERE>
System.out.println("p=" + p);
68
69
70
71
72
73
74
/* create point q using p.getLocation() */
<YOUR CODE HERE>
System.out.println("q="+q);
75
76
77
78
79
/* translate q up 3 and left 1 */
80
<YOUR CODE HERE>
81
System.out.println("q="+q);
82
/* make q refer to p */
<YOUR CODE HERE>
System.out.println("q="+q);
83
84
85
86
87
88
}
89
D-D-
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY