A class implementing an interface hierarchy does so in the same manner as a regular single interface. To the implementing class, the extended interface acts as a meta-interface that encapsulates all of the members of the interface hierarchy. This enhances the ability to implement more advanced interface polymorphism. You can implement any of the interfaces in the hierarchy.
For example:
INTERFACE ISedan INHERITS IVehicle, ICar :
INTERFACE ICoupe INHERITS IVehicle, ICar :
INTERFACE IPickup INHERITS IVehicle, ITruck :
In the above example, three interfaces, ISedan, ICoupe, and IPickup inherit from the existing interfaces.
The following figure depicts the interface hierarchy where interface ISedan, ICoupe, and IPickup inherits member prototypes from the existing interfaces IVehicle, ICar, and ITruck.
Figure 10. Using interface hierarchy
The three classes that implement each extended interface are:
CLASS Altima INHERITS Nissan IMPLEMENTS ISedan :
CLASS Mustang INHERITS Ford IMPLEMENTS ICoupe :
CLASS Tundra INHERITS Toyota IMPLEMENTS IPickup :
An application making use of these types can choose to program to the interfaces via polymorphism.
For all three classes, both the function TYPE-OF and the Progress.Lang.Class method IsA( ) will return true for IVehicle. The first two, Altima and Mustang, will both return true for ICar. Class Tundra will return true for IPickup.
PUBLIC METHOD LOGICAL handleVehicle(INPUT refVehicle AS CLASS IVehicle):
IF TYPE-OF(refVehicle, "ICar") EQ TRUE
THEN THIS-OBJECT:handleCar(refVehicle).
ELSE IF TYPE-OF(refVehicle, "ITruck") EQ TRUE
THEN THIS-OBJECT:handleTruck(refVehicle).
ELSE THIS-OBJECT:handleGeneric(refVehicle).
The above example is of a client programming to the interfaces. All the three classes are valid as parameters to this method. The first two is passed into handleCar( ) method, while the third is passed to handleTruck( ) method.