package database;

import java.util.Collection;

/**
 * This class is derived from section 2.4.
 *
 * ScheduleList is the repository of Schedules.
 * @author kdavis22
 */
abstract class ScheduleList {

   /**
    * The collection of Schedules.
    */
   Collection<Schedule> data;

   /**
     * Add the given Schedule to the given ScheduleList. The name of the given Schedule
     * must not be the same as a Schedule already on the ScheduleList. The Schedule must 
     * have a Quarter, published, year, and collection of courses. 
     */
    /*@
     ensures
       //
       // A Schedule is on the output ScheduleList if and only if it is the new Schedule
       // to be added or it is in the input ScheduleList.
       //
       (\forall Schedule schedOther ;
           data.contains(schedOther) <==>
               schedOther.equals(sched) || \old(data).contains(schedOther));
     @*/
   abstract void add(Schedule sched);

   /**
     * Remove the given Schedule from the given ScheduleList. The given Schedule must 
     * already be on the ScheduleList. 
     */
     /*@
      requires
        //
        // The given Schedule is in the given ScheduleList.
        //
        data.contains(sched);

      ensures
        //
        // A Schedule is in the output ScheduleList if and only if it is not the existing
        // Schedule to be deleted and it is in the input ScheduleList.
        //
        (\forall Schedule schedOther ;
            data.contains(schedOther) <==>
                !schedOther.equals(sched) && \old(data).contains(schedOther));
     @*/
   abstract void remove(Schedule sched);

   /**
     * Change the given old Schedule to the given new Schedule The old and new Schedules 
     * must not be the same. The old Schedule must already be on the ScheduleList. The new 
     * Schedule must meet the same conditions as for the input to the AddSchedule 
     * operation.
     */
     /*@
      requires
        //
        // The old and new Schedules are not the same.
        //
        !oldSched.equals(newSched);

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