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 * @author Tomáš Müller 009 * @version IFS 1.3 (Instructor Sectioning)<br> 010 * Copyright (C) 2016 Tomáš Müller<br> 011 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 012 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 013 * <br> 014 * This library is free software; you can redistribute it and/or modify 015 * it under the terms of the GNU Lesser General Public License as 016 * published by the Free Software Foundation; either version 3 of the 017 * License, or (at your option) any later version. <br> 018 * <br> 019 * This library is distributed in the hope that it will be useful, but 020 * WITHOUT ANY WARRANTY; without even the implied warranty of 021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 022 * Lesser General Public License for more details. <br> 023 * <br> 024 * You should have received a copy of the GNU Lesser General Public 025 * License along with this library; if not see 026 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 027 */ 028public class Course { 029 private Long iCourseId; 030 private String iCourseName; 031 032 /** 033 * Constructor 034 * @param courseId course id 035 * @param courseName course name 036 */ 037 public Course(long courseId, String courseName) { 038 iCourseId = courseId; iCourseName = courseName; 039 } 040 041 /** 042 * Course id that was provided in the constructor 043 * @return course id 044 */ 045 public Long getCourseId() { return iCourseId; } 046 047 /** 048 * Course name that was provided in the constructor 049 * @return course name 050 */ 051 public String getCourseName() { return iCourseName == null ? "C" + iCourseId : iCourseName; } 052 053 @Override 054 public int hashCode() { 055 return getCourseId().hashCode(); 056 } 057 058 @Override 059 public boolean equals(Object o) { 060 if (o == null || !(o instanceof Course)) return false; 061 Course c = (Course)o; 062 return getCourseId().equals(c.getCourseId()); 063 } 064 065 @Override 066 public String toString() { return getCourseName(); } 067}