1    WITH Discrete_Set; 
 2    WITH Ada.text_io;
 3 
 4     PROCEDURE Class_set_test IS
 5     
 6     -- enumerated types are ordered
 7     -- enumerated types require instantiations for variables holding
 8     --  their values to be directly printed
 9     -- enumarted types have attributes
10    
11     -- fruit is an enumerated type and the elements are listed below
12       TYPE fruit IS (apple, berry, cherry, plum, peach, apricot, mango);
13    
14    
15       TYPE cars IS (GTO, LTD, Z240Z, XKE, RX7,Y740);
16    
17     -- the following two lines are instantiations of the generic type 
18     -- Element_type defined in the package specification
19        PACKAGE fruitSet IS NEW Discrete_Set(Element_Type => fruit);
20        PACKAGE carSet IS NEW Discrete_Set (Element_Type => cars);
21    
22    -- the following three lines are instantiations inserted to allow
23    -- direct printing of variables holding these enumerated type values
24        PACKAGE fruit_io IS NEW ada.text_io.enumeration_io (fruit);
25        PACKAGE car_io IS NEW ada.text_io.enumeration_io(cars);
26        PACKAGE boolean_io IS NEW ada.text_io.enumeration_io(boolean);
27       
28       setA,  setB, setC : fruitSet.Set_Type;  
29       setD,  setE, setF : carset.Set_Type;
30       isInSet : boolean;
31    
32    BEGIN
33       setA := fruitSet.Universal_Set; -- initializing setA to Universal_Set
34       setB := fruitSet.Empty_Set;     -- initializing setB to the Empty_Set
35       setC := fruitSet."+"(setA, setB);  -- initializing setC to the union of setA and setB
36    
37       isInSet := fruitSet.is_Member (setA, apple);
38       ada.text_io.put (" apple is in setA is: ");
39       boolean_io.put (isInSet);
40       ada.text_io.new_line;
41      
42       isInSet := carSet.is_Member (setD, LTD);  -- spurious answer
43       ada.text_io.put (" ford is in setD is: ");
44       boolean_io.put (isInSet);
45    
46       isInSet := fruitSet.is_Member (setB, apple);
47       ada.text_io.put (" apple is in setB is: ");
48       boolean_io.put (isInSet);
49       ada.text_io.new_line;
50    
51       FOR i IN fruit LOOP
52          fruit_io.put (i,10);
53       END LOOP;      
54       ada.text_io.new_line;
55     
56       FOR i IN fruit'first..fruit'last LOOP
57          fruit_io.put (i,10);
58       END LOOP;      
59       ada.text_io.new_line;
60    
61    end Class_Set_Test;
62