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_07.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_07 is
21
22 type Train is(One, Two);
23
24 package EIO is new Enumeration_IO(Train);
25 use EIO;
26
27 procedure Approach_Points(T : in Train) is
28 begin
29 Put("...Approach_Points");
30 Put(T);
31 New_Line;
32 end Approach_Points;
33
34 procedure Cross_Points(T : in Train) is
35 begin
36 Put(T);
37 Put_Line(" Crossing_Points");
38 end Cross_Points;
39
40 procedure Go_Away_From_Points(T : in Train) is
41 begin
42 Put(" Go_Away_From_Points...");
43 Put(T);
44 New_Line;
45 end Go_Away_From_Points;
46
47 task Points is
48 entry Cross(T : in Train);
49 end Points;
50
51 task body Points is
52 begin
53 loop
54 select
55 accept Cross(T : in Train) do
56 Cross_Points(T);
57 end Cross;
58 or terminate;
59 end select;
60 end loop;
61 end Points;
62
63 task Train1;
64
65 task body Train1 is
66 begin
67 Approach_Points(One);
68 Points.Cross(One);
69 Go_Away_From_Points(One);
70 end Train1;
71
72 task Train2;
73
74 task body Train2 is
75 begin
76 Approach_Points(Two);
77 Points.Cross(Two);
78 Go_Away_From_Points(Two);
79 end Train2;
80
81begin
82
83 null;
84
85end Trains_07;