Java Reference
In-Depth Information
{
for ( int i = 0; i < numberOfCourses; i++)
{
coursesEnrolled[i].copyCourseInfo(courses[i]);
courseGrades[i] = cGrades[i];
}
sortCourses();
}
The default constructor initializes the instance variables to their default values.
public Student()
{
super ();
numberOfCourses = 0;
sId = 0;
isTuitionPaid = false ;
coursesEnrolled = new Course[6];
for ( int i = 0; i < 6; i++)
coursesEnrolled[i] = new Course();
courseGrades = new char [6];
for ( int i = 0; i < 6; i++)
courseGrades[i] = '*';
}
The method toString returns the grade report as a string. If the student has paid his
or her tuition, the grades and the GPA are returned. Otherwise, three stars are
returned in place of each grade. The definition of this method is:
public String toString()
{
String gReport;
gReport = "Student Name: "
+ super .toString() + "\r\n"
+ "Student ID: " + sId + "\r\n"
+ "Number of courses enrolled: "
+ numberOfCourses + "\r\n"
+ String.format("%-12s%-15s%-8s%-6s%n",
"Course No", "Course Name",
"Credits", "Grade");
for ( int i = 0; i < numberOfCourses; i++)
{
gReport = gReport + coursesEnrolled[i];
if (isTuitionPaid)
gReport = gReport
+ String.format("%8s%n", courseGrades[i]);
 
Search WWH ::




Custom Search