public ColoredPoint(double x, double y, String color) { Point constructor, extract the x and y coordinate from point and initialize the classes x, y coordinate, and the color input: Point: p String: color output: None public ColoredPoint(Point p, String color) { SYOUR CODE HERE> /* return the color of this point Input: None Output: String: Color of point public String getColor() { } /* update the ColoredPoints color Input: String: color Output: None
public ColoredPoint(double x, double y, String color) { Point constructor, extract the x and y coordinate from point and initialize the classes x, y coordinate, and the color input: Point: p String: color output: None public ColoredPoint(Point p, String color) { SYOUR CODE HERE> /* return the color of this point Input: None Output: String: Color of point public String getColor() { } /* update the ColoredPoints color Input: String: color Output: None
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
![50
public void setColor(String color) { <YOUR CODE HERE>}
51
52 이 ㅎ
@0verride public boolean equals(Object o) {
if ( o instanceof ColoredPoint ) {
ColoredPoint p = (ColoredPoint)o;
53
54
55
return x == p.x && y == p.y && color
p.color;
56
57
else
58
return false;
59
60
// if we override equals() we have to override hashCode()
@0verride public int hashCode() { return Objects.hash(x, y, color); }
61
62 of E
65
66
/*
tostring method
Input:
67
68
69
None
70
Ουtρut :
71
String: (x,y,color) (No spaces)
*/
@0verride public String toString() {
SYOUR CODE HERE>
72
73 of e
74
75
76
public static void main(String[] args) {
ColoredPointp = new ColoredPoint( x: 2, y: 3, color: "red");
System.out.println("p = " + p);
/* create point q using getlocation() */
Point q = p.getLocation();
/* q and p will have the same co-ordinates, but q has no color */
System.out.println("q="+q);
System.out.println("p equal to q? " + p.equals(q));
ColoredPoint g2 = new ColoredPoint(q, color: "red");
System.out.println("q2="+g2);
System.out.println("q2 equal to p? "+p.equals(g2));
77 ►
78
79
80
81
82
83
84
85
86
87
88
q2. translate( dx: 3, dy: -1); /*p and q have different values */
System.out.println("q2
System.out.println("q2 equal to p? "+p.equals(q2));
89
90
"+g2);
91
92
q2 = p; /* now q2 and p are the same (p==q) */
System.out.println("q2 = "+g2);
System.out.println("q2 equal to p? "+p.equals(g2));
93
94
95
96
q2. setColor("blue");
System.out.println("q2 = "+g2);
System.out.println("p
System.out.println("q2 equal to p? "+p.equals(g2));
97
98
99
"+p);
100
101
D-D
a D-](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbeaaa11f-b4ba-46f9-b461-ce84893e9827%2F48a35e62-fabd-483a-a1ae-37826788b8c8%2Fpdz6ost_processed.png&w=3840&q=75)
Transcribed Image Text:50
public void setColor(String color) { <YOUR CODE HERE>}
51
52 이 ㅎ
@0verride public boolean equals(Object o) {
if ( o instanceof ColoredPoint ) {
ColoredPoint p = (ColoredPoint)o;
53
54
55
return x == p.x && y == p.y && color
p.color;
56
57
else
58
return false;
59
60
// if we override equals() we have to override hashCode()
@0verride public int hashCode() { return Objects.hash(x, y, color); }
61
62 of E
65
66
/*
tostring method
Input:
67
68
69
None
70
Ουtρut :
71
String: (x,y,color) (No spaces)
*/
@0verride public String toString() {
SYOUR CODE HERE>
72
73 of e
74
75
76
public static void main(String[] args) {
ColoredPointp = new ColoredPoint( x: 2, y: 3, color: "red");
System.out.println("p = " + p);
/* create point q using getlocation() */
Point q = p.getLocation();
/* q and p will have the same co-ordinates, but q has no color */
System.out.println("q="+q);
System.out.println("p equal to q? " + p.equals(q));
ColoredPoint g2 = new ColoredPoint(q, color: "red");
System.out.println("q2="+g2);
System.out.println("q2 equal to p? "+p.equals(g2));
77 ►
78
79
80
81
82
83
84
85
86
87
88
q2. translate( dx: 3, dy: -1); /*p and q have different values */
System.out.println("q2
System.out.println("q2 equal to p? "+p.equals(q2));
89
90
"+g2);
91
92
q2 = p; /* now q2 and p are the same (p==q) */
System.out.println("q2 = "+g2);
System.out.println("q2 equal to p? "+p.equals(g2));
93
94
95
96
q2. setColor("blue");
System.out.println("q2 = "+g2);
System.out.println("p
System.out.println("q2 equal to p? "+p.equals(g2));
97
98
99
"+p);
100
101
D-D
a D-

Transcribed Image Text:import java.util.Objects;
2
public class ColoredPoint extends Point {
private String color = "black";
3
6.
/*
Override the Point classes constructor with the x and y coordinate
initialize the color variable
8
input:
double x: x coordinate
double y: y coordinate
String color: color
10
11
12
13
output:
14
None
15
public ColoredPoint(double x, double y, String color) {
<YOUR CODE HERE>
16
wwww
17
18
<YOUR CODE HERE>
19
20
/*
Point constructor, extract the x and y coordinate from point and initialize
the classes x, y coordinate, and the color
input:
Point: p
String: color
21
22
23
24
25
26
27
output:
28
None
29
public ColoredPoint(Point p, String color) {
<YOUR CODE HERE>
30
31
32
<YOUR CODE HERE>
33
34
35
/*
36
return the color of this point
37
Input:
38
None
39
Output:
40
String: Color of point
41
*/
public String getColor () { <YOUR CODE HERE> }
/*
update the ColoredPoints color
42
43
44
45
Input:
46
String: color
47
Output:
48
None
49
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 3 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