001package org.cpsolver.studentsct.online; 002 003import org.cpsolver.studentsct.model.Offering; 004import org.cpsolver.studentsct.model.Student; 005 006/** 007 * An online reservation. A simple class modeling any reservation of a student. This class is particularly useful when a model containing only the given 008 * student is constructed (to provide him/her with a schedule or suggestions). 009 * 010 * @author Tomáš Müller 011 * @version StudentSct 1.3 (Student Sectioning)<br> 012 * Copyright (C) 2014 Tomáš Müller<br> 013 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 014 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 015 * <br> 016 * This library is free software; you can redistribute it and/or modify 017 * it under the terms of the GNU Lesser General Public License as 018 * published by the Free Software Foundation; either version 3 of the 019 * License, or (at your option) any later version. <br> 020 * <br> 021 * This library is distributed in the hope that it will be useful, but 022 * WITHOUT ANY WARRANTY; without even the implied warranty of 023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 024 * Lesser General Public License for more details. <br> 025 * <br> 026 * You should have received a copy of the GNU Lesser General Public 027 * License along with this library; if not see <a href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>. 028 * 029 */ 030public class OnlineReservation extends org.cpsolver.studentsct.reservation.Reservation { 031 private int iType; 032 private int iLimit; 033 private boolean iApply; 034 private boolean iOverride; 035 036 /** 037 * Constructor 038 * @param type reservation type 039 * @param id reservation unique id 040 * @param offering reservation offering 041 * @param priority reservation priority 042 * @param over true when the reservation allows the student to be assigned over the limit 043 * @param limit reservation limit 044 * @param apply true if the reservation applies to the given student 045 * @param mustUse true if the reservation must be used 046 * @param allowOverlap true if the reservation allows for time overlaps 047 * @param expired true if the reservation is expired 048 * @param override true if the reservation is reservation override 049 */ 050 public OnlineReservation(int type, long id, Offering offering, int priority, boolean over, int limit, boolean apply, boolean mustUse, boolean allowOverlap, boolean expired, boolean override) { 051 super(id, offering, priority, mustUse, over, allowOverlap); 052 iType = type; 053 iLimit = limit; 054 iApply = apply; 055 iOverride = override; 056 setExpired(expired); 057 } 058 059 /** 060 * Constructor 061 * @param type reservation type 062 * @param id reservation unique id 063 * @param offering reservation offering 064 * @param priority reservation priority 065 * @param over true when the reservation allows the student to be assigned over the limit 066 * @param limit reservation limit 067 * @param apply true if the reservation applies to the given student 068 * @param mustUse true if the reservation must be used 069 * @param allowOverlap true if the reservation allows for time overlaps 070 * @param expired true if the reservation is expired 071 */ 072 public OnlineReservation(int type, long id, Offering offering, int priority, boolean over, int limit, boolean apply, boolean mustUse, boolean allowOverlap, boolean expired) { 073 this(type, id, offering, priority, over, limit, apply, mustUse, allowOverlap, expired, false); 074 } 075 076 public int getType() { 077 return iType; 078 } 079 080 @Override 081 public double getReservationLimit() { 082 return iLimit; 083 } 084 085 @Override 086 public boolean isApplicable(Student student) { 087 return iApply; 088 } 089 090 public boolean isOverride() { 091 return iOverride; 092 } 093 094 @Override 095 public boolean mustBeUsed() { 096 if (iOverride) 097 return mustBeUsedIgnoreExpiration(); 098 return super.mustBeUsed(); 099 } 100 101 @Override 102 public double getLimitCap() { 103 return getReservationLimit(); 104 } 105}