Question: this is in java, thanks for your help In this assignment, you must code an interface named Shape with three methods and create a class

this is in java, thanks for your help

In this assignment, you must code an interface named Shape with three methods and create a class named Rectangle that implements Shape.

The interface Shape represents a closed geometrical shape. It has three methods.

1. draw: This has no parameters and returns void. The method draws the shape on the screen.

2. getArea: The method has no parameters and returns the area of the shape. The return type is double.

3. getPerimeter: The method has no parameters and returns the perimeter of the shape. The return type is double.

The class Rectangle represents a rectangle and implements the Shape interface. Besides meeting that requirement, the class must satisfy the following criteria.

1. It must have exactly two double fields: width and height. Do not use any other identifiers for these two fields and do not define any other fields in the class.

2. It must have exactly one constructor that accepts the width and height in that order. It must store these values in the respective fields.

3. It must override toString and equals. You must use the standard Eclipse generated code for this.

The draw method must draw the rectangle using System.out.println. Simply print width number of asterisks in height number of lines. For example, see the following code and resultant output.

Shape rectangle1 = new Rectangle(4, 5); rectangle1.draw();

****

****

****

****

****

Please submit an Eclipse project as a zip file that opens correctly.

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!