Lab09 Home Task Manual
Lab09 Home Task Manual
Draw UML class diagrams of the following task. You are required to bring this design with you and
submit to your lab instructor.
From the Rectangle class, derive a class named Cuboid that contains
•A data field named height in addition to length and width,
•Two functions named setHeight and getHeight() to set and get value of height data field, and
•A member function named cuboidArea() to calculate the area of a cuboid (length x width x height)
Draw UML diagram for each class and show inheritance relationship between these classes.
Implement both classes and in the main() function, create an instance of SpecializationField class. Invoke
appropriate functions to display all attribute values as well as the validation of the specialization for this
particular instance.
5.2.2 Task-2
Derive a class named SpacePoint to imagine a point in a three-dimensional space and has following
additional features:
•A data member Z of type integer to represent the z-coordinate of a point in space
•A no-argument constructor that constructs a point with coordinates (0,0,0)
•A constructor with three arguments that constructs a point with three specified coordinate values
•An accessor function, which returns the value of data field Z
•A function named spaceDistance to return the distance between two points in the space
Implement both the classes and in the main() create two points with different dimensions and invoke
appropriate function to display the distance between these two points.