package resources.course;

import java.util.Collection;
import java.util.List;

/**
 * A CourseDB is a representation of a collection of courses.
 * 
 * @author aakoeppe
 * 
 */

public abstract class CourseDB {
   public Collection<Course> courses;

   public CourseDB() { }
   
   /**
    * Adds a course to the CourseDB.
    * 
    * @param c
    *           the course to add
    */
   /*
   pre:
       //
       // There is no Course in the input DB with the same subject and course number
       // as the Course to be added.
       //
        !exists (Course c_other;
           courses.contains(c_other);
              c_other.subject.equals(c.subject) 
                 && c_other.courseNumber == c.courseNumber)
                 
         &&
      // 
      // The subject of the given course is not empty
      //
      (c.subject != null)
     
         &&
     
      //
      // The course number is not empty and greater than 99 and less than 600
      //
      (c.courseNumber != null) && (c.courseNumber > 99) 
         && (c.courseNumber < 600)
     
         &&
     
      //
      // The course title is not null
      //
      (c.courseTitle != null)
      
         &&
         
      //
      // The course units is not null and greater than 0 and less than 5
      //
      (c.courseUnits != null) && (c.courseUnits > 0)
         && (c.courseUnits < 5)
      
         &&
         
      //
      // The wtu is not null and greater than 0
      //
      (c.workTimeUnits != null) && (c.workTimeUnits > 0)
      
         &&
         
      //
      // The course has a type
      //
      (c.courseTypes != null)
      
         &&
         
      //
      // The computer lab boolean is not null
      //
      (c.computerLab != null);

      //
      // A room is in the output data if and only if it is the new
      // record to be added or it is in the input data.
      //
   post:
      forall (Course c_other;
         courses'.contains(c_other) iff
            c_other.equals(c) || courses.contains(c_other));
   */
   public abstract void addCourse(Course c);
   
   /**
    * Removes a course from the DB.
    * 
    *     * @param c
    *           the course to remove
    */
   /*
   pre:
      //
      // Delete the given course record from the given CourseDB. The given 
      // course must already be in the input db.
      //
      courses.contains(c);

   post:
      //
      // A course is in the output data if and only if it is the new
      // course to be added or it is in the input data.
      //
      forall ( Course c_other ;
         (courses'.contains(c_other)) iff
            !c_other.equals(c) && courses.contains(c_other));
  */

   public abstract void removeCourse(Course c);
   
   /**
    * Returns sorted list of Courses.
    */
    /* 
    post:
        //
        // The output list is sorted lexicographically by name of 
        // Course, according to the semantics of 
        // java.lang.String.compareto().
        //
        forall (int i; (i>=0) && (i < return.size() - 1);
           return.get(i).courseNumber.compareTo(return.get(i + 1).courseNumber) < 0);
     
    */
   public abstract List<Course> viewCourses();
}