home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / hotdogs.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  2.3 KB  |  89 lines

  1.                                    -- Chapter 25 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure HotDogs is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    task Gourmet is
  11.       entry Make_A_Hot_Dog(Serial_Number : INTEGER);
  12.    end Gourmet;
  13.  
  14.    procedure Get_Dog(Serial_Number : INTEGER) renames
  15.                                           Gourmet.Make_A_Hot_Dog;
  16.  
  17.    task body Gourmet is
  18.    begin
  19.       Put_Line("I am ready to make a hot dog for you");
  20.  
  21.       accept Make_A_Hot_Dog(Serial_Number : INTEGER) do
  22.          Put_Line("This will be the first hot dog");
  23.          Put("Put hot dog in bun ");
  24.          Put_Line("and add mustard");
  25.          delay 0.8;
  26.       end Make_A_Hot_Dog;
  27.  
  28.       for Index in 1..4 loop
  29.          accept Make_A_Hot_Dog(Serial_Number : INTEGER) do
  30.             Put("This will be hot dog number");
  31.             Put(Serial_Number);
  32.             New_Line;
  33.             Put("Put hot dog in bun ");
  34.             Put_Line("and add mustard");
  35.             delay 0.8;
  36.          end Make_A_Hot_Dog;
  37.       end loop;
  38.  
  39.       accept Make_A_Hot_Dog(Serial_Number : INTEGER) do
  40.          Put_Line("This will be the last hot dog");
  41.          Put("Put hot dog in bun ");
  42.          Put_Line("and add mustard");
  43.          delay 0.8;
  44.       end Make_A_Hot_Dog;
  45.  
  46.       Put_Line("I am out of hot dogs");
  47.    end Gourmet;
  48.  
  49. begin
  50.    for Index in 1..6 loop
  51.       Get_Dog(Index);
  52.       Put_Line("Eat the resulting hot dog");
  53.       New_Line;
  54.    end loop;
  55.    Put_Line("I am not hungry any longer");
  56. end HotDogs;
  57.  
  58.  
  59. -- Result of execution
  60.  
  61. -- I am ready to make a hot dog for you
  62. -- This will be the first hot dog
  63. -- Put hot dog in bun and add mustard
  64. -- Eat the resulting hot dog
  65. --
  66. -- This will be hot dog number     2
  67. -- Put hot dog in bun and add mustard
  68. -- Eat the resulting hot dog
  69. --
  70. -- This will be hot dog number     3
  71. -- Put hot dog in bun and add mustard
  72. -- Eat the resulting hot dog
  73. --
  74. -- This will be hot dog number     4
  75. -- Put hot dog in bun and add mustard
  76. -- I am out of hot dogs
  77. -- Eat the resulting hot dog
  78. --
  79. -- This will be hot dog number     5
  80. -- Put hot dog in bun and add mustard
  81. -- Eat the resulting hot dog
  82. --
  83. -- This will be the last hot dog
  84. -- Put hot dog in bun and add mustard
  85. -- Eat the resulting hot dog
  86. --
  87. -- I am not hungry any longer
  88.  
  89.