Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show work and final display output :) Implement, in seven differentJava files, (all of which are within the package cs22.shapes an inheritance hierarchy with

image text in transcribed

Please show work and final display output :)

Implement, in seven differentJava files, (all of which are within the package cs22.shapes an inheritance hierarchy with the following classes: 1. A parentclass Solid that can represent solid shapes. This class has aprivate String instance variable name that is initialized through its constructor. The class provides an accessor for name and an instance method volume (that computes the volume of the solid. It also overrides the toString) method to clearly state what kind of class it is and what its instance variables, if any, are. 2. A child class of Solid called Sphere that has a radius instance variable. This class overrides the volume) and toString methods in the parent Research and use the correct formula for the volume of a sphere. Achild class of Solid called Cone that has instance variables radiusandheight. This class overrides the volumeand toString( methods in the parent. Research and use the correct formula for the volume of a cube. 3. 4. A child class of Solid called RectangularPyramid that has instance variables length and width of the rectangular base and height of the pyramid. This class overrides the volumeand toString) methods in the parent Research and use the correct formula for the volume of a rectangular pyramid A child class of Solid called RectangularCuboi height instance variables. This class overides the volume() and toString () methods in the parent Research and use the correct formula for the volume of a rectangular cuboid. d that has length, width and 6. A child class of RectangularCuboid called Cube. This class overrides the toString method in the parent. 7. A driver class called SolidTester that creates 2 spheres (radii 8 and 10), 1 rectangular cuboid (length, width and height 5, 4 and 3 respectively), 2 cubes (lengths 10 and 5) and 2 cones (radius and height 3 and 5 for the first cone, and 8 and 2 for the second cone) and one rectangular pyramid (5 and 10 for the base dimensions and 4 for height) and stores them in a Solid array. Use a loop on this array to test the methods volume and toStringonach object in the array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions