Reimplement the program of Exercise 10.7 such that classes TwoDimensionalShape and…
Reimplement the program of Exercise 10.7 such that classes TwoDimensionalShape and ThreeDimensionalShape implement an IShape interface, rather than extending abstract class Shape.
Implement the Shape hierarchy shown in Fig. 9.3. Each TwoDimensionalShape should contain method Area to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have methods Area and Volume to calculate the surface area and volume of the three-dimensional shape, respectively. Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy. The program should output the string representation of each object in the array. Also, in the loop that processes all the shapes in the array, determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its Area. If a shape is a ThreeDimensionalShape, display its Area and Volume.