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.

Must be in Java. need help. here is the partial Coloring interface

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 } 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!