home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / lovelace / rooms.adb < prev    next >
Encoding:
Text File  |  1995-10-24  |  1.1 KB  |  47 lines

  1.  
  2.  
  3. with Text_IO, Ustrings;
  4. use  Text_IO, Ustrings;
  5.  
  6. package body Rooms is
  7.  
  8.  procedure Connect(Source : access Room; Dir : in Direction; 
  9.                    Destination : access Thing'Class;
  10.                    Bidirectional : in Boolean := True) is
  11.  begin
  12.    Source.Destinations(Dir) := Destination;
  13.    if Bidirectional then
  14.      Room_Access(Destination).Destinations(Reverse_Direction(Dir)) := Source;
  15.    end if;
  16.  end Connect;
  17.  
  18.  procedure Disconnect(Source : access Room; Dir : in Direction; 
  19.                       Bidirectional : in Boolean := True) is
  20.  begin
  21.    if Bidirectional then
  22.      -- if (Source.Destinations(Dir).all'Tag in Room'Class) then
  23.        Room_Access(Source.Destinations(Dir)).Destinations(Reverse_Direction(Dir)) := null;
  24.      -- end if;
  25.    end if;
  26.    Source.Destinations(Dir) := null;
  27.  end Disconnect;
  28.  
  29.  function What_Is(From : access Room; Dir : in Direction) return Thing_Access is
  30.  begin
  31.   return From.Destinations(Dir);
  32.  end What_Is;
  33.  
  34.  procedure Put_View(T : access Room; Agent : access Thing'Class) is
  35.  begin
  36.   Put("You are ");
  37.   Put(Long_Description(T));
  38.   Put_Line(".");
  39.   Put_Contents(T, Agent, "You see:");
  40.  end Put_View;
  41.  
  42. end Rooms;
  43.  
  44.  
  45.  
  46.  
  47.