📄 department.java
字号:
package Entities;
import dslib.list.LinkedListUos;
import dslib.dictionary.arrayed.ArrayedPKeyedDictUos;
/** A representation of a department at the university. */
public class Department
{
public LinkedListUos instructors;
public ArrayedPKeyedDictUos courses;
protected int subjectCode;
protected String name;
protected int tuitionCategory;
public String name()
{
return name;
}
public int subjectCode()
{
return subjectCode;
}
public int tuitionCategory()
{
return tuitionCategory;
}
/** Make a new department */
public Department(String deptName, int newCode, int category)
{
name = deptName;
subjectCode = newCode;
tuitionCategory = category;
courses = new ArrayedPKeyedDictUos(10);
instructors = new LinkedListUos();
}
/** Add a new course to this department */
public void addCourse(Course newCourse)
{
courses.insert(new Integer(newCourse.number()), newCourse);
}
/** Add an instructor to this department */
public void addInstructor(Instructor i)
{
instructors.insert(i);
}
/** Add a new course section for a course in this department */
public void addCourseSection(int courseNum, CourseSection newSect)
{
((Course)courses.obtain(new Integer(courseNum))).addSection(newSect);
}
public String toString()
{
String result = "";
if (!instructors.isEmpty())
result += "\nCurrent intructors : " + instructors.toString();
else
result += "\nNo instructors yet";
if (!courses.isEmpty())
result += "\nCurrent courses : " + courses.toString();
else
result += "\nNo courses yet";
result += "\nSubject code : " + subjectCode;
result += "\nName : " + name;
result += "Tuition Category : " + tuitionCategory;
return result;
}
} /* end of Department */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -