Previous topic |
Ada Home Page |
Index
Records example
-- various constants used in data types
space : constant := ' '; -- ascii space
max_name_lenf : constant := 25; -- max char in name
max_phone_lenf : constant := 10; -- max char in phone
min_age : constant := 16; -- minage of person
max_age : constant := 80; -- max age of person
min_weight : constant := 0.00; -- min person wight
max_weight : constant := 250.00; -- max person weight
-- various types and sub-types for record declarations
subtype names is STRING(1 .. max_name_lenf);
subtype phones is STRING(1 .. max_phone_lenf);
type sexes is (male, female);
subtype ages is INTEGER range min_age .. max_age;
subtype weights is FLOAT range min_weight .. max_weight;
-- input/output of sex enumerated type
package sex_io is new ENUMERATION_IO( sexes );
-- declaration of record data type
type persons is record
name : names := ( others => space); -- name
phone : phones := ( others => space); -- phone
sex : sexes; -- sex of person
age : ages; -- age of person
weight: weights; -- weight of person
end record;
this_person,
that_person : persons; -- various people
Previous topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 27 Feb 96