callnum.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 59 行

JAVA
59
字号
package Entities;

/**	This class contains a numeric description of a course section */
public class CallNum
{

	/**	a complete description of the course */
	protected int courseNum;
	
	protected int deptNum;
	
	protected int sectionNum;
	
	/**	Return the course */
	public int courseNum()
	{
		return courseNum;
	}
	
	/** Return the department the class belongs */
	public int deptNum()
	{
		return deptNum;
	}
	
	/**	Returnt the class section */
	public int sectionNum()
	{
		return sectionNum;
	}
	
	/**	Create a new call number from the arguments */
	public CallNum(int dept, int cou, int sect)
	{
		deptNum = dept;
		courseNum = cou;
		sectionNum = sect;
	}
	
	/**	Does other represent the same course as Current */
	public boolean sameCourse(CallNum other)
	{
		return ((other.deptNum() == deptNum) && 
			(other.courseNum() == courseNum) && 
			(other.sectionNum() == sectionNum));
	}

	/**	Return a string representation of the section name */
	public String toString()
	{
		String result = "\nDepartment Number : " + deptNum;
		result += "\nCourse Number : " + courseNum;
		result += "\nSection Number : " + sectionNum;
		return result;
	}


} /* end of CallNum */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?