program Inheritance 2
 


program Inheritance_2;

uses vehicles, CarTruck;

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

var Unicycle : Vehicle;
Sedan : Car;
Semi : Truck;

begin

Unicycle.Init(1, 12.0);
Sedan.Init(4, 2100.0, 5);
Semi.Init(1, 25000.0, 18, 5000.0);

WriteLn('The unicycle weighs ', Unicycle.Get_Weight:5:1,
' pounds, and has ', Unicycle.Get_Wheels, ' wheel.');

WriteLn('The car weighs ', Sedan.Get_Weight:7:1,
' pounds, and carries ', Sedan.Passengers,
' passengers.');

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

with Semi 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;
end.



Result of execution

The unicycle weighs 12.0 pounds, and has 1 wheel.
The car weighs 2100.0 pounds, and carries 5 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