Yurttas/PL/IL/Ada-95/F/06/trains/trains 05.adb
Jump to navigation
Jump to search
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_05.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_05 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 is
28 begin
29 Put_Line("...Approach_Points");
30 end Approach_Points;
31
32 procedure Cross_Points(T : in Train) is
33 begin
34 Put(T);
35 Put_Line(" Crossing_Points");
36 end Cross_Points;
37
38 procedure Go_Away_From_Points is
39 begin
40 Put_Line(" Go_Away_From_Points...");
41 end Go_Away_From_Points;
42
43 task Points is
44 entry Cross(T : in Train);
45 end Points;
46
47 task body Points is
48 begin
49 loop
50 accept Cross(T : in Train) do
51 Cross_Points(T);
52 end Cross;
53 end loop;
54 end Points;
55
56 task Train1;
57
58 task body Train1 is
59 begin
60 Approach_Points;
61 Points.Cross(One);
62 Go_Away_From_Points;
63 end Train1;
64
65 task Train2;
66
67 task body Train2 is
68 begin
69 Approach_Points;
70 Points.Cross(Two);
71 Go_Away_From_Points;
72 end Train2;
73
74begin
75
76 null;
77
78end Trains_05;