001package org.cpsolver.studentsct.reservation; 002 003import java.util.Collection; 004 005import org.cpsolver.studentsct.model.Offering; 006 007 008/** 009 * Group reservation. This is basically a {@link IndividualReservation}, but 010 * students cannot be assigned over the limit and the priority is lower than on 011 * individual reservations. Also, a different limit than the number of students 012 * in the group can be provided. 013 * 014 * <br> 015 * <br> 016 * 017 * @version StudentSct 1.3 (Student Sectioning)<br> 018 * Copyright (C) 2007 - 2014 Tomas Muller<br> 019 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 020 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 021 * <br> 022 * This library is free software; you can redistribute it and/or modify 023 * it under the terms of the GNU Lesser General Public License as 024 * published by the Free Software Foundation; either version 3 of the 025 * License, or (at your option) any later version. <br> 026 * <br> 027 * This library is distributed in the hope that it will be useful, but 028 * WITHOUT ANY WARRANTY; without even the implied warranty of 029 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 030 * Lesser General Public License for more details. <br> 031 * <br> 032 * You should have received a copy of the GNU Lesser General Public 033 * License along with this library; if not see 034 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 035 */ 036public class GroupReservation extends IndividualReservation { 037 private double iLimit; 038 039 /** 040 * Constructor 041 * @param id unique id 042 * @param limit reservation limit (-1 for unlimited) 043 * @param offering offering for which the reservation is 044 * @param studentIds one or more students 045 */ 046 public GroupReservation(long id, double limit, Offering offering, Long... studentIds) { 047 super(id, offering, studentIds); 048 iLimit = limit; 049 } 050 051 /** 052 * Constructor 053 * @param id unique id 054 * @param limit reservation limit (-1 for unlimited) 055 * @param offering offering for which the reservation is 056 * @param studentIds one or more students 057 */ 058 public GroupReservation(long id, double limit, Offering offering, Collection<Long> studentIds) { 059 super(id, offering, studentIds); 060 iLimit = limit; 061 } 062 063 /** 064 * Group reservations are of the second highest priority 065 */ 066 @Override 067 public int getPriority() { 068 return 200; 069 } 070 071 /** 072 * Group reservations can not be assigned over the limit. 073 */ 074 @Override 075 public boolean canAssignOverLimit() { 076 return false; 077 } 078 079 /** 080 * Reservation limit 081 */ 082 @Override 083 public double getReservationLimit() { 084 return iLimit; 085 } 086 087 /** 088 * Set reservation limit (-1 for unlimited) 089 * @param limit reservation limit, -1 if unlimited 090 */ 091 public void setReservationLimit(double limit) { 092 iLimit = limit; 093 } 094 095 /** 096 * Overlaps are allowed for individual reservations. 097 */ 098 @Override 099 public boolean isAllowOverlap() { 100 return false; 101 } 102}