Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Shape (Abstract) Triangle Ellipse Circle EquilateralTriangle Consider the following shapes; Ellipse, Circle, Triangle, EquilateralTriangle Each shape should have a name, a method to compute its

image text in transcribed

Shape (Abstract) Triangle Ellipse Circle EquilateralTriangle Consider the following shapes; Ellipse, Circle, Triangle, EquilateralTriangle Each shape should have a name, a method to compute its perimeter, and another method to compute its area. The name should be an instance variable of type String. De superclass Shape. Notice that the area and perimeter are common to all Shapes, but we don't know how to compute the area or perimeter for a general shape . sign your inheritance hierarchy with the common features in the .The ellipse class has a major and minor axes a and b, respectively. The constructor should assign the largest value to a and smallest to b. The area and perimeters of an ellipse are Perimeter P 2b)-(a-b/2 [Note that if a-br, then P 2] .The Triangle class has three instance variables side, side2, and side3. The formula for the area and perimeter of a general Triangle with sides A, B, and C is given by AREA-S(S-A)SB(S -C) PERIMETER-A+ B + C A+B+ The condition for any three positive values to make sides of a Triangle is: . 4 + B > C and B + C>,A and C + A > B . You need to check this condition inside the constructor. If it is not satisfied, print an error message and terminate the program, otherwise make your Triangle object. The three sides of the equilateral triangle are equal Make a Test class where you make objects from the different classes and store them in an array of type Shape. Then, make a loop and print the objects name, area, and perimeter through toString i.e. you need to override toString in the Shape class only

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

What is the purpose of brand management?

Answered: 1 week ago