    001package org.cpsolver.studentsct.reservation;
    002
    003import org.cpsolver.studentsct.model.Course;
    004import org.cpsolver.studentsct.model.Student;
    005
    006/**
    007 * Course reservation. Students are matched based on their course requests.
    008 *
    009 * <br>
    010 * <br>
    011 *
    012 * @author  Tomáš Müller
    013 * @version StudentSct 1.3 (Student Sectioning)<br>
    014 *          Copyright (C) 2007 - 2014 Tomáš Müller<br>
    015 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    016 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    017 * <br>
    018 *          This library is free software; you can redistribute it and/or modify
    019 *          it under the terms of the GNU Lesser General Public License as
    020 *          published by the Free Software Foundation; either version 3 of the
    021 *          License, or (at your option) any later version. <br>
    022 * <br>
    023 *          This library is distributed in the hope that it will be useful, but
    024 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    025 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    026 *          Lesser General Public License for more details. <br>
    027 * <br>
    028 *          You should have received a copy of the GNU Lesser General Public
    029 *          License along with this library; if not see
    030 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    031 */
    032public class CourseReservation extends Reservation {
    033    private Course iCourse;
    034
    035    /**
    036     * Reservation priority (lower than individual and group reservations)
    037     */
    038    public static final int DEFAULT_PRIORITY = 400;
    039    /**
    040     * Course reservation does not need to be used
    041     */
    042    public static final boolean DEFAULT_MUST_BE_USED = false;
    043    /**
    044     * Course reservations can not assign over the limit.
    045     */
    046    public static final boolean DEFAULT_CAN_ASSIGN_OVER_LIMIT = false;
    047    /**
    048     * Overlaps are not allowed for course reservations.
    049     */
    050    public static final boolean DEFAULT_ALLOW_OVERLAP = false;
    051
    052    /**
    053     * Constructor
    054     * @param id unique id
    055     * @param course course offering on which the reservation is set
    056     */
    057    public CourseReservation(long id, Course course) {
    058        super(id, course.getOffering(), DEFAULT_PRIORITY, DEFAULT_MUST_BE_USED, DEFAULT_CAN_ASSIGN_OVER_LIMIT, DEFAULT_ALLOW_OVERLAP);
    059        iCourse = course;
    060    }
    061
    062    /**
    063     * Reservation limit (-1 for unlimited)
    064     */
    065    @Override
    066    public double getReservationLimit() {
    067        return iCourse.getLimit();
    068    }
    069
    070    /**
    071     * Course offering
    072     * @return course offering
    073     */
    074    public Course getCourse() {
    075        return iCourse;
    076    }
    077
    078    /**
    079     * Check the area, classifications and majors
    080     */
    081    @Override
    082    public boolean isApplicable(Student student, Course course) {
    083        return course != null && course.equals(getCourse());
    084    }
    085}