Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following class definitions abstract class Shapet protected Point p; //top-left corner public Shape) p new Point) 1 public Shape(int x, int y) {

image text in transcribed

Consider the following class definitions abstract class Shapet protected Point p; //top-left corner public Shape) p new Point) 1 public Shape(int x, int y) { p new point (x,y); } public String toString() { return string . format("%d", perimeter()); } public abstract int perimeterO; class Circle extends Shape [ private int radius; public circle) public Circle(int x, int y, int r) f super(x,y); public int perimeter) return (int) (Math.PIradius); class Rectangle extends Shape f private int width, height; public Rectangle th public Rectangle(int x, int y, int w, int h)t super(x,y); widthW; height h; public int perimeter) return width height) 2; You are required to modify the Shape class and implement the Comparable interface. You will need to override the compareTo(Shape s) method. The comparison is based on the perimeter of shapes. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified Shape Write the Shape class in the answer box below assuming that the Rectangle and Circle have been done for you For example: Test Result Rectanglei new Rectangle(2e, 38, 48, 58); System.out.println(rl) 188 Answer (penalty regime: 0 %) 1 abstract class Shape implements Comparable

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago