Java Reference
In-Depth Information
else
gReport = gReport
+ String.format("%8s%n", "***");
}
gReport = gReport
+ "\r\nTotal number of credit hours: "
+ getHoursEnrolled() + "\r\n";
return gReport;
} //end toString
The definitions of the methods getStudentId , getIsTuitionPaid ,
getNumberOfCourses , getCourse , and getGrade are given next:
public int getStudentId()
{
return sId;
}
public boolean getIsTuitionPaid()
{
return isTuitionPaid;
}
public int getNumberOfCourses()
{
return numberOfCourses;
}
public Course getCourse( int i)
{
1
0
Course temp = new Course();
temp.copyCourseInfo(coursesEnrolled[i]);
return temp;
}
public char getGrade( int i)
{
return courseGrades[i];
}
The method getHoursEnrolled calculates and returns the total credit hours that a
student is taking. These credit hours are needed to calculate both the GPA and the
billing amount. The total credit hours are calculated by adding the credit hours of each
course in which the student is enrolled. Because the credit hours for a course are in the
private data member of an object of type Course , we use the method getCredits of
the class Course to retrieve the credit hours. The definition of this method is:
Search WWH ::




Custom Search