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_09.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_09 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 T1,
36 T2,
37 T3 : Train;
38
39 procedure Approach_Points(T : in Train_Id) is
40 begin
41 Put("...Approach_Points");
42 Put(T);
43 New_Line;
44 end Approach_Points;
45
46 procedure Cross_Points(T : in Train_Id) is
47 begin
48 Put(T);
49 Put_Line(" Crossing_Points");
50 end Cross_Points;
51
52 procedure Go_Away_From_Points(T : in Train_Id) is
53 begin
54 Put(" Go_Away_From_Points...");
55 Put(T);
56 New_Line;
57 end Go_Away_From_Points;
58
59 task body Points is
60 begin
61 loop
62 select
63 accept Cross(T : in Train_Id) do
64 Cross_Points(T);
65 end Cross;
66 or terminate;
67 end select;
68 end loop;
69 end Points;
70
71 task body Train is
72 begin
73 T := T+1;
74 Approach_Points(T);
75 Points.Cross(T);
76 Go_Away_From_Points(T);
77 end Train;
78
79begin
80
81 null;
82
83end Trains_09;