graderecord.java

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

JAVA
110
字号
package Entities;

/**	This class contains information about a grade a
	student recieved for a course. */
public class GradeRecord
{

	/**	constructor */
	public GradeRecord(CallNum secN, String newG, int y, int t, int c)
	{
		callNum = secN;
		grade = newG;
		year = y;
		term = t;
		credits = c;
	}

	/**	Call number  */
	protected CallNum callNum;
	
	/**	The year the course offered */
	protected int year;
	
	/**	The term course offered */
	protected int term;
	
	/**	The grade assign to the course taken */
	protected String grade;
	
	/**	The credit units assign tothe course */
	protected int credits;

	/**	Return the department number */
	public int deptNum()
	{
		return callNum.deptNum();
	}
	
	/**	Return the course number for the grade */
	public int courseNum()
	{
		return callNum.courseNum();
	}
	
	/**	Return the section number */
	public int sectionNum()
	{
		return callNum.sectionNum();
	}

	/**	Return the section  */
	public CallNum callNum()
	{
		return callNum;
	}
	
	/**	Return the year the course offered */
	public int year()
	{
		return year;
	}
	
	/**	Return the term course offered */
	public int term()
	{
		return term;
	}
	
	/**	Return the grade assign to the course taken */
	public String grade()
	{
		return grade;
	}
	
	/**	Return the credit units assign tothe course */
	public int credits()
	{
		return credits;
	}
	
	/**	 Assign a grade for the student */
	public void setGrade(String g)
	{
		grade = g;
	}
	
	/**	Is the current grade history object for the
		same course as the argument */ 
	public boolean sameCourse(GradeRecord other)
	{
		return ((deptNum() == other.deptNum()) &&
			(courseNum() == other.courseNum()) &&
			(sectionNum() == other.sectionNum())); 
	}
	
	/**	Return a string representation of the grade history */
	public String toString()
	{
		String result = "\nClass Information : ";
		result += callNum.toString();
		result += "\nYear : " + year;
		result += "\nTerm : " + term;
		result += "\nCredits : " + credits;
		result += "\nGrade : " + grade + "\n";
		
		return result;
	}

} /* end of GradeRecord */

⌨️ 快捷键说明

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