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