Java Programming I am using intellij to write my code 1. Implement the shape hierarchy shown above, in which Shape, TwoDeimentionalShape and ThreeDimentionalShape should be abstract classes. 2....


Java Programming


I am using intellij to write my code


1. Implement the shape hierarchy shown above, in which
Shape, TwoDeimentionalShape and
ThreeDimentionalShape should be abstract classes.
2. Include abstract method getArea in the
TwoDimensionalShape class. Also, include abstract
methods getArea and getVolume in the
ThreeDimensionalShape class.


3. Each subclass of TwoDimensionalShape should contain
method getArea to calculate the area of the twodimensional shape.
4. Each subclass of ThreeDimensionalShape should have
getArea and getVolume to calculate the surface area and
volume.
5. Override the toString method in each concrete class (third
level), to include basic information about the object, e.g.,
“Sphere object, radius = 4”


• Create a test program that uses an array of Shape references
to objects of each concrete class in the hierarchy. For
example,
Shape[] shapes = new Shapes [5];
Shape[0] = new Circle(2);
• Create a loop that process all the shapes in the array, print
basic information for each object. Also, determine whether
each shape is TwoDimensionalShape or
ThreeDimensionalShape:
• If it is TwoDimensionalShape, display its area.
• If it is ThreeDimensionalShape, display its area and volume



• Area<br>• Circle: pi*r^2<br>Square: side*side<br>• Triangle:<br>Let ab.c be the lengths of the sides of a triangle. The area is given by.<br>Area = VP(p-a)(p-b)(p-e)<br>where p is half the perimeter, or<br>a+b+c<br>2<br>Sphere: 4*pi*r^2<br>Cube: 6*side*side<br>Cuboid: 2*length*width + 2*length*height + 2*height*weight<br>Volume<br>• Sphere: V =<br>Cube: side^3<br>Cuboid: length*width*height<br>

Extracted text: • Area • Circle: pi*r^2 Square: side*side • Triangle: Let ab.c be the lengths of the sides of a triangle. The area is given by. Area = VP(p-a)(p-b)(p-e) where p is half the perimeter, or a+b+c 2 Sphere: 4*pi*r^2 Cube: 6*side*side Cuboid: 2*length*width + 2*length*height + 2*height*weight Volume • Sphere: V = Cube: side^3 Cuboid: length*width*height
Shape<br>TwoDimentionalShape<br>ThreeDimentionalShare<br>Circle<br>Square<br>Triangle<br>Sphere<br>Cube<br>Cuboid<br>

Extracted text: Shape TwoDimentionalShape ThreeDimentionalShare Circle Square Triangle Sphere Cube Cuboid

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here