Lab Assignment (10.09.2024) (1)
Lab Assignment (10.09.2024) (1)
Lab Assignment-6
1. Create an abstract class Shape with methods calc_area() and calc_volume(). Derive three classes
Sphere(with attribute radius) , Cone(with attributes radius, height) and Cylinder(with attributes radius,
height), Box(with attributes length, breadth, height) from it. Calculate the area and volume of all the
given shapes.
2. Define an abstract class called Staff with data members name and address and an abstract method
called display() . Define two subclasses of this class called FullTimeStaff (with additional attributes
department and salary) and PartTimeStaff (with additional attributes number_of_hours,
rate_per_hour). Define appropriate constructors for each class. Create 5 objects, which could be of
either of FullTimeStaff or PartTimeStaff class by asking the user’s choice and thereby implementing
runtime polymorphism. Display the details of all FullTimeStaff class objects and all PartTimeStaff class
objects using the display() method defined in each class.