program Inheritance 3
 


program Inheritance_3;

uses vehicles, CarTruck;

{ ************************ main program ************************** }

var Unicycle : Vehicle;
Sedan : array[1..3] of Car;
Semi_Point : ^Truck;
Index : integer;

begin

Unicycle.Init(1, 12.0);
for Index := 1 to 3 do
Sedan[Index].Init(4, 2100.0, 5 + Index);
New(Semi_Point);
Semi_Point^.Init(1, 25000.0, 18, 5000.0);

WriteLn('The unicycle weighs ', Unicycle.Get_Weight:5:1,
' pounds, and has ', Unicycle.Get_Wheels, ' wheel.');
for Index := 1 to 3 do
WriteLn('The car weighs ', Sedan[Index].Get_Weight:7:1,
' pounds, and carries ', Sedan[Index].Passengers,
' passengers.');

WriteLn('The semi has a wheel loading of ',
Semi_Point^.Wheel_Loading:8:1,
' pounds per tire,');
WriteLn(' and has an efficiency of ', Semi_Point^.Efficiency:5:1,
' percent.');

with Semi_Point^ do
begin
WriteLn('The semi has a wheel loading of ', Wheel_Loading:8:1,
' pounds per tire,');
WriteLn(' and has an efficiency of ', Efficiency:5:1,
' percent.');
end;
Dispose(Semi_Point);
end.



Result of execution

The unicycle weighs 12.0 pounds, and has 1 wheel.
The car weighs 2100.0 pounds, and carries 6 passengers.
The car weighs 2100.0 pounds, and carries 7 passengers.
The car weighs 2100.0 pounds, and carries 8 passengers.
The semi has a wheel loading of 1666.7 pounds per tire,
and has an efficiency of 83.3 percent.
The semi has a wheel loading of 1666.7 pounds per tire,
and has an efficiency of 83.3 percent.

(c) Shilpa Sayura Foundation 2006-2017