Need Help ?

Home >> Assignments >> computer_science >> Write, debug, and test a group of classes in an object-oriented language of your choice that implement the following object

(Solved): Write, debug, and test a group of classes in an object-oriented language of your choice that implement the following object ...



Write, debug, and test a group of classes in an object-oriented language of your choice that implement the following object hierarchy. Include another class called TestObjectHierarchy that contains a main method and demonstrates the functionality of all of the classes.

Here are some helpful geometry reminders: Perimeter of an ellipse: https://www.mathsisfun.com/geometry/ellipse-perimeter.html Area of an ellipse: https://www.math.hmc.edu/funfacts/ffiles/10006.3.shtml Circumference of a circle: 2 * ? * r Area of a circle: ? * r2 Perimeter of a rectangle: 2 * (w + h) Area of a rectangle: w * h interface Shape double getPerimeter() double getArea() class Ellipse implements Shape double getMajorRadius() void setMajorRadius(double r) double getMinorRadius() void setMinorRadius(double r) class Circle extends Ellipse double getRadius() // A Circle is an Ellipse whose major and minor radii are congruent; this rule can be enforced by overriding the appropriate methods in the base class void setRadius(double r) double getCircumference() // this is the same as the perimeter calculated in the base class class Rectangle implements Shape double getWidth() void setWidth(double w) double getHeight() void setHeight(double b) class Square extends Rectangle double getSideLength() // a Square is a Rectangle whose height and width are congruent; this rule can be enforced by overriding the appropriate methods in the base class void setSideLength(double s)

Your Own Object Hierarchy Now that you have had some practice, design and implement your own object hierarchy. Just like the first part of the assignment, this should be a hierarchy that might be useful in the real world. Include the following: At least one abstract base class At least one interface At least two concrete classes (at least one of these should inherit from the abstract base class you created, and at least one should implement the interface you created) At least one overridden method At least one delegated method A test program to show off your hierarchy’s functionality Include a description of the hierarchy in the test program’s header comment as well as descriptions of all the classes in their respective header comments.



We have an Answer from Expert

View Expert Answer

Get Expert Solution


Here is the code for these classes :

1. Interface Shape

public interface Shape
{
    public double getPerimeter();
    public double getArea();
}

2. Class Ellipse

import java.lang.*;
public class Ellipse implements Shape
{
    private double majorRadius;
    private double minorRadius;
  
    public Ellipse()

We have an Answer from Expert

Buy This Answer $5

Place Order

QUICK ORDER

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing
Order Now