Question: Create an interface named Shape which has the following abstract methods. Recall that abstract methods do not have an implementation when you define them.


Create an interface named Shape which has the following abstract methods. Recall that abstract methods do not have an implementation when you define them. Only the classes that implement the interface will provide the implementations. Note that if you provide JavaDoc in the interface for these abstract methods, you do not need to create JavaDoc in the class where you implement the method and simply use the {@inheritDoc} for the JavaDoc block. public double get Area() - Computes the area of a geometric shape. public void scale(double factor) - Scales the geometric shape's measurements (length, width, height, etc.) by the factor received as a parameter. Rectangle Class Implements Shape: Create a class named Rectangle which implements the interface Shape and has the following private instance properties and public interface. 1. Instance Properties: a. int x-The x coordinate of the upper left corner of the Rectangle. b. int y-The y coordinate of the upper left corner of the Rectangle. c. double length - The length of the Rectangle. d. double width - The width of the Rectangle. 2. Public Interface: a. public Rectangle(int x, int y, double length, double width) - A workhorse constructor which initializes the instance properties using the received parameters. b. public double getArea() - The implementation of the abstract getArea() method. It returns the area of the Rectangle based on the length and width. Note, the area of a Rectangle is length width. c. public void scale(double factor) The implementation of the abstract scale(double factor) method. It scales the length and width instance properties by a scaled factor received from the parameter. Multiple the length and width instance properties by the factor (this is scale transformation). d. public boolean equals(Object o) - This method returns true if two Rectangle objects have the same length and width and false, otherwise. e. public String toString() - Returns a String representation of the Rectangle object that include the x, y, length, and width instance properties. An example String is as follows: "Rectangle [x = 10, y = 15, length = 60.0, width = 75.0]". f. A set of getters and setters for each instance property. Triangle Class Implements Shape: Create a class named Triangle which implements the interface Shape and has the following private instance properties and public interface. 1. Instance Properties: a. double base-The base of the Triangle. b. double height - The height of the Triangle. 2. Public Interface: a. public Triangle(double base, double height) - A workhorse constructor which initializes the instance properties using the received parameters. b. public double getArea() - The implementation of the abstract getArea() method. It returns the area of the Triangle based on the base and height. Note, the area of a Triangle is 0.5 * base * height. c. public void scale(double factor) - The implementation of the abstract scale(double factor) method. It scales the base and height instance properties by a scaled factor received from the parameter. Multiple the base and height instance properties by the factor (this is scale transformation). d. public boolean equals(Object o) - This method returns true if two Triangle objects have the same base and height and false, otherwise. e. public String toString() - Returns a String representation of the Triangle object that include the base and height instance properties. An example String is as follows: "Triangle [base = 30.0, height = 45.0]". f. A set of getters and setters for each instance property. Shape Tester Class: In the main method of your ShapeTester class, you should test the classes and their corresponding methods listed above. That is, you should test the constructors, getArea(), scale(), equals(), and toString() methods of both the Rectangle and Triangle classes. Additional Notes: Make sure you include JavaDoc comments for all methods and classes including parameter and return descriptions. Make sure that all classes are named correctly. There is no explicit validation checking needed for this Lab assignment. Rubric: Correctly create the Shape interface Declared abstract getArea() method Declared abstract scale() method Task Interface Shape Implements the Shape interface Constructor correctly implemented Getters and setters correctly implemented equals() method correctly implemented toString() method correctly implemented Grade 222 Class Rectangle 6 6 6 6 6 getArea() method correctly implemented scale() method correctly implemented 7 7 Class Triangle Implements the Shape interface Constructor correctly implemented Getters and setters correctly implemented 6 6 6 equals() method correctly implemented 6 toString() method correctly implemented 6 getArea() method correctly implemented 7 scale() method correctly implemented 7 Adequate JavaDoc included for all classes and methods and followed the Miami University coding guidelines 6 Total 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
