Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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
expand button
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
expand button
Transcribed Image Text:Shape TwoDimentionalShape ThreeDimentionalShare Circle Square Triangle Sphere Cube Cuboid
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY