Create an interface named Shape which has the following abstract methods. Recall that abstract methods do...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Financial Management for Public Health and Not for Profit Organizations
ISBN: 978-0132805667
4th edition
Authors: Steven A. Finkler, Thad Calabrese
Posted Date:
Students also viewed these programming questions
-
This question concerns lexical grammars. (a) Tree Adjoining Grammars contain two types of elementary tree. (i) What are these trees called? [1 mark] (ii) If one were building a grammar for English...
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
Problem 5-47 Amortizing Loans and Inflation (LO3) Suppose you take out a $108,000, 20-year mortgage loan to buy a condo. The interest rate on the loan is 5%. To keep things simple, we will assume you...
-
Michelle has just received an inheritance from her grandfathers estate. She will be entering college in 3 1/2 years, and wants to immediately purchase three compound- 2 interest investment...
-
Let's denote the price of a nonmaturing bond (called a consol) as Pb. The equation that indicates this price is Pb = I/r, where I is the annual net income the bond generates and r is the nominal...
-
When did Artificial Intelligence first begin to be studied? Your answer should be more detailed than a simple date.
-
The Sterling Tire Companys income statement for 2013 is as follows: STERLING TIRE COMPANY Income Statement For the Year Ended December 31, 2013 Sales (20,000 tires at $60 each) ...........$1,200,000...
-
what are potential risks of Juan and Elena Hernandez's disciplinary style on the psychological development of their children. Identify one theoretical perspective that can be used to explain the...
-
Draw a payoff diagram for each of the following portfolios a. Buy a put X = $20, buy a call X = $30. b. Buy a put X = $50 (which costs $16.12), sell a put X = $45 (which costs $12.52), sell a put X =...
-
Oriole Ltd. purchased land and constructed a service station, at a total cost of $452700. On January 2, 2022, when construction was completed, Oriole sold the service station and land to a major oil...
-
On January 2, 2023, Tom Company invested $4,150,000 in Jerry Ltd. for 40% of its outstanding common shares. At this time, the book value (equity) of Jerry Ltd. was $8,400,000. Jerry pays out 25% of...
-
A ski resort received $8,800 cash in advance for ski lift passes, which allow 5 months of skiing (December 1 - April 30). The ski resort recorded the cash receipt with a debit to Cash and a credit to...
-
Brown Cow Dairy uses the aging approach to estimate bad debt expense. The ending balance of each account receivable is aged on the basis of three time periods as follows: (1) not yet due, $14,000;...
-
During the current year, Sun Electronics, Incorporated, recorded credit sales of $730,000. Based on prior experience, it estimates a 2 percent bad debt rate on credit sales. a. On November 13 of the...
-
On a recent trip to India, Mr. Chen, a prominent Chinese executive, dined with his Indian client, Mr. Patel. Mr. Chen commented that the food was spicy, which Mr. Patel interpreted as an opportunity...
-
Write a paper about how diet relates to breast cancer in women study design to use: case control study purpose & rationale the purpose of this final project is to utilize the methods and...
-
Nitrogen is compressed to a density of \(4 \mathrm{~kg} / \mathrm{m}^{3}\) under an absolute pressure of \(400 \mathrm{kPa}\). Determine the temperature in degrees Celsius.
-
A regulation basketball is initially flat and is then inflated to a pressure of approximately \(24 \mathrm{lb} / \mathrm{in}^{2}\) absolute. Consider the air temperature to be constant at...
-
The presence of raindrops in the air during a heavy rainstorm increases the average density of the air-water mixture. Estimate by what percent the average air-water density is greater than that of...
Study smarter with the SolutionInn App