Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following Coloring interface and Point class //Coloring interface public interface Coloring{ public String getColor(); } //Point class public class Point { private

imageimageimageimage

Given the following 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 == the same } else { return false; } } public int getX() { return x; other.y; //TRUE if they are } public int getY() { return y; } public void setLocation(int x, int y) { this.x = x; this.y = y; } public String toString() { return "(" + x + || II ' 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).

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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions