Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

Who are the classical economists advocating the INCENTIVE PRINCIPLE

Answered: 1 week ago