Assignment 04
Assignment 04
Assignment 04
(Inheritance)
1. Write a program that defines a shape class with a constructor that gives value to width
and height. Then define two sub-classes triangle and rectangle, that calculate the area
of the shape. In the main, define two objects a triangle and a rectangle and then call
the area () function.
2. Write a program with a mother class animal. Inside it define a name and an age
variables, and set_value () function. Then create two sub class Zebra and Dolphin
which write a message telling the age and name of animal, also giving some extra
information for both sub class (e.g. place of origin).place of origin of zebra is Earth
and place of origin of dolphin is water.