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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started