home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 20 - Program 5
- with Text_IO;
- use Text_IO;
-
- procedure Variant1 is
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
-
- type POWER is (GAS, STEAM, DIESEL, NONE);
-
- type VEHICLE (Engine : POWER) is
- record
- Model_Year : INTEGER range 1888..1992;
- Wheels : INTEGER range 2..18;
- case Engine is
- when GAS => Cylinders : INTEGER range 1..16;
- when STEAM => Boiler_Size : INTEGER range 5..22;
- Coal_Burner : BOOLEAN;
- when DIESEL => Fuel_Inject : BOOLEAN;
- when NONE => Speeds : INTEGER range 1..15;
- end case;
- end record;
-
- Ford : VEHICLE(GAS);
- Truck : VEHICLE(DIESEL);
- Schwinn : VEHICLE(NONE);
- Stanley : VEHICLE(STEAM);
-
- begin
-
- Ford.Model_Year := 1956; -- Component assignment
- Ford.Wheels := 4;
- Ford.Cylinders := 8;
-
- Ford := (GAS, 1956, 4, 8); -- Positional aggregate assignment
-
- -- Named aggregate assignment
- Ford := (Model_Year => 1956, Cylinders => 8, Engine => GAS,
- Wheels => 4);
-
- Stanley.Model_Year := 1908;
- Stanley.Wheels := 4;
- Stanley.Boiler_Size := 21;
- Stanley.Coal_Burner := FALSE;
- -- Mixed aggregate assignment
- Stanley := (STEAM, 1908, 4, Coal_Burner => FALSE,
- Boiler_Size => 21);
-
- Schwinn.Speeds := 10;
- Schwinn.Wheels := 2;
- Schwinn.Model_Year := 1985;
-
- Truck.Model_Year := 1966;
- Truck.Wheels := 18;
- Truck.Fuel_Inject := TRUE;
-
- end Variant1;
-
-
-
-
- -- Result of Execution
-
- -- (No results are output.)
-
-