package database;

import java.util.Collection;

/**
 * This class is derived from section 2.3.3.
 *
 * RoomList is the repository of Room information.
 * @author kdavis22
 */
abstract class RoomList {

   /**
    * The collection of Rooms.
    */
   Collection<Room> data; 

   /**
    * Add the given Room to the given RoomList. The number of the given room must not be 
    * the same as a Room already on the RoomList. All Rooms must have a capacity and time 
    * pattern availability.
    */ 
   /*@
    ensures
       //
       // A Room is on the output RoomList if and only if it is the new Room
       // to be added or it is in the input RoomList.
       //
       (\forall Room roomOther ;
           data.contains(roomOther) <==>
               roomOther.equals(rm) || \old(data).contains(roomOther));
     @*/
   abstract void add(Room rm);
   
   /**
    * Delete the given Room from the given RoomList. The given room must already be on the
    * RoomList.  
    */
    /*@
     requires
       //
       // The given Room is in the given RoomList.
       //
       data.contains(rm);

     ensures
       //
       // A Room is in the output RoomList if and only if it is not the existing
       // Room to be deleted and it is in the input RoomList.
       //  
       (\forall Room roomOther ;
           data.contains(roomOther) <==>
               !roomOther.equals(rm) && \old(data).contains(roomOther));
     @*/
   abstract void remove(Room rm);
  
   /**
    * Change the given old Room to the given new Room. The old and new Rooms must not be 
    * the same. The old Room must already be on the RoomList. The new Room must meet the 
    * same conditions as for the input to the AddRoom operation. 
    */ 
    /*@
      requires
        //
        // The old and new Rooms are not the same.
        //
        !oldRm.equals(newRm);

       ensures
         //
         // A Room is in the output RoomList if and only if it is the new Room
         // to be added or it is in the input RoomList, and it is not the old Room.
         //
         (\forall Room roomOther ;
             data.contains(roomOther) <==>
                roomOther.equals(newRm) || 
                    \old(data).contains(roomOther) &&
                        !roomOther.equals(oldRm));
     @*/ 
   abstract void change(Room oldRm, Room newRm);
}