001package org.cpsolver.instructor.model; 002 003/** 004 * Course of a teaching request. If a course is marked as exclusive, all assignments of an instructor must have 005 * the same course. It is also possible to mark the course as same common, which require all assignments that are 006 * given to a single instructor to share the same common part of the course (e.g., the lecture). 007 * 008 * @version IFS 1.3 (Instructor Sectioning)<br> 009 * Copyright (C) 2016 Tomas Muller<br> 010 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 011 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 012 * <br> 013 * This library is free software; you can redistribute it and/or modify 014 * it under the terms of the GNU Lesser General Public License as 015 * published by the Free Software Foundation; either version 3 of the 016 * License, or (at your option) any later version. <br> 017 * <br> 018 * This library is distributed in the hope that it will be useful, but 019 * WITHOUT ANY WARRANTY; without even the implied warranty of 020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 021 * Lesser General Public License for more details. <br> 022 * <br> 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not see 025 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 026 */ 027public class Course { 028 private Long iCourseId; 029 private String iCourseName; 030 private boolean iExclusive; 031 private boolean iCommon; 032 033 /** 034 * Constructor 035 * @param courseId course id 036 * @param courseName course name 037 * @param exclusive exclusivity of the course 038 * @param sameCommon ensure that multiple assignments given to the same instructor share the common part 039 */ 040 public Course(long courseId, String courseName, boolean exclusive, boolean sameCommon) { 041 iCourseId = courseId; iCourseName = courseName; 042 iExclusive = exclusive; iCommon = sameCommon; 043 } 044 045 /** 046 * Course id that was provided in the constructor 047 * @return course id 048 */ 049 public Long getCourseId() { return iCourseId; } 050 051 /** 052 * Course name that was provided in the constructor 053 * @return course name 054 */ 055 public String getCourseName() { return iCourseName == null ? "C" + iCourseId : iCourseName; } 056 057 /** 058 * If a course is marked as exclusive, all assignments of an instructor must have 059 * the same course. 060 * @return true if this course is exclusive 061 */ 062 public boolean isExclusive() { return iExclusive; } 063 064 /** 065 * Whether to ensure that multiple assignments given to the same instructor share the common part. If enabled, all assignments of this 066 * course that are given to the same student must share the sections that are marked as common (see {@link Section#isCommon()}). 067 * @return true means that an instructor cannot be given two assignments of this course that do NOT share the common part 068 */ 069 public boolean isSameCommon() { return iCommon; } 070 071 @Override 072 public int hashCode() { 073 return getCourseId().hashCode(); 074 } 075 076 @Override 077 public boolean equals(Object o) { 078 if (o == null || !(o instanceof Course)) return false; 079 Course c = (Course)o; 080 return getCourseId().equals(c.getCourseId()); 081 } 082 083 @Override 084 public String toString() { return getCourseName(); } 085}