Question
Must be in Java. need help. here is the partial Coloring interface and Point class //Coloring interface public interface Coloring{ public String getColor(); } //Point
Must be in Java. need help.
here is the partial Coloring interface and Point class
//Coloring interface
public interface Coloring{
public String getColor();
}
//Point class
public class Point {
private int x;
private int y;
public Point() {
this(0, 0);
}
public Point(int x, int y) {
setLocation(x, y);
}
//compare the x and y of two points
public boolean equals(Object o) {
if (o instanceof Point) {
Point other = (Point) o;
return x == other.x && y == other.y; //TRUE if they are the same
} else {
return false;
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setLocation(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return "(" + x + ", " + y + ")";
}
}
Write the ColoringPoint class such that it implements the Coloring interface and extends the Point class so that it can have colors. Override the toString() method to print out the coordinates and color of the Point, override the equals() method so that it compares color as well. Write the necessary constructors, accessors, and mutators.
Write a client class, ColoringClient, and create two different objects of the ColoringPoint class (CP_blue and CP_orange). Print the color of each object and compare if they are equal (x=x, y=y, color=color).
| 2 public class point { 3 4 } 5Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started