Yurttas/PL/IL/Ada-95/F/06/trains/trains 10.adb

 1--
 2-- Copyright(C) 1998
 3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4--
 5-- Permission to use, copy, modify, and distribute this
 6-- software and its documentation for EDUCATIONAL purposes
 7-- and without fee is hereby granted provided that this
 8-- copyright notice appears in all copies.
 9--
10 
11-- date   : January 1, 1998.
12-- authorĀ : Salih Yurttas.
13
14-- trains_10.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_10 is
21
22  type Train_Id is new Integer range 0..7;
23
24  package Train_IO is new Integer_IO(Train_Id);
25  use Train_IO;
26
27  T : Train_Id := 0;
28
29  task Points is
30    entry Cross(T : in Train_Id);
31  end Points;
32
33  task type Train;
34
35  TA : array(1..3) of Train;
36
37  procedure Approach_Points(T : in Train_Id) is
38  begin
39    Put("...Approach_Points");
40    Put(T);
41    New_Line;
42  end Approach_Points;
43
44  procedure Cross_Points(T : in Train_Id) is
45  begin
46    Put(T);
47    Put_Line(" Crossing_Points");
48  end Cross_Points;
49
50  procedure Go_Away_From_Points(T : in Train_Id) is
51  begin
52    Put("     Go_Away_From_Points...");
53    Put(T);
54    New_Line;
55  end Go_Away_From_Points;
56
57  task body Points is
58  begin
59    loop
60      select
61        accept Cross(T : in Train_Id) do
62          Cross_Points(T);
63        end Cross;
64      or terminate;
65      end select;
66    end loop;
67  end Points;
68
69  task body Train is
70  begin
71    T := T+1;
72    Approach_Points(T);
73    Points.Cross(T);
74    Go_Away_From_Points(T);
75  end Train;
76
77begin
78
79  null;
80
81end Trains_10;