Question: 1 . Declare the headers ( class declaration ) for the classes in the class diagram. 2 . Declare no - argument constructors for Shape,

1. Declare the headers(class declaration) for the classes in the class diagram.
2. Declare no-argument constructors for Shape, TwoDimensionalShape, and
ThreeDimensionalShape classes.
3. Declare the instance variables for Circle(radius), Square(side), Sphere(radius) and
Cube(side) classes. 4. Declare one-argument and no-argument constructors for Circle, Square, Sphere,
and Cube classes.
5. Declare get and set methods for instance variables in Circle, Square, Sphere, and
Cube classes
6. Declare computeArea method for Circle, Square, Sphere, and Cube classes.
7. Declare toString methods for all the classes. Class Shapes toString method should
return the string Shape. The toString method of each of the subclasses in the
hierarchy should return a string containing the classs name the string is a and the
result of a call the superclasss toString method.
8. Write a separate driver class(application class) that creates one object of each of
the classes Circle, Square Sphere and Cube, and invokes their toString methods.
The output for each object should show the is-a relationships between that objects
class and its superclasses.Sample Output:
Circle: Circle is a TwoDimesnionalShape is a Shape
Circle's area is 4.91
Square: Square is a TwoDimesnionalShape is a Shape
Square's area is 6.25
Sphere: Sphere is a ThreeDimesnionalShape is a Shape
Sphere's area is 176.71
Sphere's volume is 220.89
Cube: Cube is a ThreeDimesnionalShape is a Shape
Cube's area is 150.00
Cube's volume is 125.00
 1. Declare the headers(class declaration) for the classes in the class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!