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

  1.  
  2. with Things, Directions;
  3. use  Things, Directions;
  4.  
  5. package Occupants is
  6.  
  7.  -- An "Occupant" is a Thing that can be inside a Room or another Occupant.
  8.  
  9.  type Occupant is abstract new Thing with private;
  10.  type Occupant_Access   is access all Occupant'Class;
  11.  
  12.  -- Dispatching subprograms:
  13.  
  14.  procedure Look(T : access Occupant);      -- Ask Occupant T to "look".
  15.  
  16.  procedure Get(Agent : access Occupant; Direct_Object : access Occupant'Class);
  17.            -- Ask Agent to get Direct_Object.  This assumes that Agent can
  18.            -- somehow access Direct_Object (i.e. is in the same room).
  19.            -- If the agent decides that it can get the object, it will
  20.            -- call May_I_Get to ask the object if that's okay.
  21.  
  22.  procedure Drop(Agent : access Occupant; Direct_Object : access Occupant'Class);
  23.            -- Ask Agent to drop Direct_Object.
  24.  
  25.  procedure Inventory(Agent : access Occupant);
  26.            -- Ask Agent to print a list of what Agent is carrying.
  27.  
  28.   procedure Go(Agent : access Occupant; Dir : in Direction);
  29.             -- Ask Agent to go the given Direction Dir (North, South, etc.)
  30.  
  31.  
  32.  -- Non-dispatching subprograms:
  33.  
  34.  procedure Put_View(T : access Occupant; Agent : access Thing'Class);
  35.  
  36.  function May_I_Get(Direct_Object : access Occupant;
  37.                     Agent : access Occupant'Class) return Boolean;
  38.            -- Ask Direct_Object if "Agent" can get this object.
  39.            -- Returns True if it's okay, else False.
  40.            -- If the object does something while being gotten (or an attempt
  41.            -- to do so) it does it in this call.
  42.  
  43.  function  May_I_Drop(Direct_Object : access Occupant;
  44.                       Agent         : access Occupant'Class) return Boolean;
  45.            -- Ask Direct_Object if "Agent" can drop this object;
  46.            -- returns True if it's okay.
  47.  
  48. private
  49.  
  50.  type Occupant is abstract new Thing with
  51.   record
  52.     null;  -- Nothing here for now.
  53.   end record;
  54.  
  55. end Occupants;
  56.  
  57.