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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
• 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
Transcribed Image 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
TwoDimentionalShape
ThreeDimentionalShare
Circle
Square
Triangle
Sphere
Cube
Cuboid
Transcribed Image Text:Shape TwoDimentionalShape ThreeDimentionalShare Circle Square Triangle Sphere Cube Cuboid
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 10 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY