001package org.cpsolver.studentsct.online; 002 003import java.util.List; 004 005import org.cpsolver.coursett.model.Placement; 006import org.cpsolver.studentsct.model.Instructor; 007import org.cpsolver.studentsct.model.Section; 008import org.cpsolver.studentsct.model.Student; 009import org.cpsolver.studentsct.model.Subpart; 010 011/** 012 * An online section. A simple extension of the {@link Section} class that allows to set the current section enrollment. 013 * This class is particularly useful when a model containing only the given student is constructed (to provide him/her with a schedule or suggestions). 014 * 015 * @version StudentSct 1.3 (Student Sectioning)<br> 016 * Copyright (C) 2014 Tomáš Müller<br> 017 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 018 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 019 * <br> 020 * This library is free software; you can redistribute it and/or modify 021 * it under the terms of the GNU Lesser General Public License as 022 * published by the Free Software Foundation; either version 3 of the 023 * License, or (at your option) any later version. <br> 024 * <br> 025 * This library is distributed in the hope that it will be useful, but 026 * WITHOUT ANY WARRANTY; without even the implied warranty of 027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 028 * Lesser General Public License for more details. <br> 029 * <br> 030 * You should have received a copy of the GNU Lesser General Public 031 * License along with this library; if not see <a href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>. 032 * 033 */ 034public class OnlineSection extends Section { 035 private int iEnrollment = 0; 036 private boolean iAlwaysEnabled = false; 037 private Integer iDayOfWeekOffset = null; 038 039 public OnlineSection(long id, int limit, String name, Subpart subpart, Placement placement, List<Instructor> instructors, Section parent) { 040 super(id, limit, name, subpart, placement, instructors, parent); 041 } 042 043 @Deprecated 044 public OnlineSection(long id, int limit, String name, Subpart subpart, Placement placement, String instructorIds, String instructorNames, Section parent) { 045 super(id, limit, name, subpart, placement, instructorIds, instructorNames, parent); 046 } 047 048 /** 049 * Set current enrollment 050 * @param enrollment current enrollment 051 */ 052 public void setEnrollment(int enrollment) { iEnrollment = enrollment; } 053 054 /** 055 * Get current enrollment 056 * @return current enrollment 057 */ 058 public int getEnrollment() { return iEnrollment; } 059 060 public void setAlwaysEnabled(boolean alwaysEnabled) { iAlwaysEnabled = alwaysEnabled; } 061 public boolean isAlwaysEnabled() { return iAlwaysEnabled; } 062 063 @Override 064 public boolean isEnabled() { 065 if (iAlwaysEnabled) return true; 066 return super.isEnabled(); 067 } 068 069 @Override 070 public boolean isEnabled(Student student) { 071 if (iAlwaysEnabled) return true; 072 return super.isEnabled(student); 073 } 074 075 @Override 076 protected int getDayOfWeekOffset() { 077 if (iDayOfWeekOffset != null) return iDayOfWeekOffset; 078 return super.getDayOfWeekOffset(); 079 } 080 public void setDayOfWeekOffset(Integer dayOfWeekOffset) { 081 iDayOfWeekOffset = dayOfWeekOffset; 082 } 083 084}