Java Reference
In-Depth Information
array coursesEnrolled by course number. The class Student is derived from
the class Person , and the variables to store the first and last name are private
members of that class. Therefore, we call the method setName of the class Person ,
and we pass the appropriate variables to set the first and last names. The definition of
the method setInfo is as follows:
public void setInfo(String fName, String lName, int ID,
int nOfCourses, boolean isTPaid,
Course[] courses, char [] cGrades)
{
setName(fName, lName);
//set the name
sId = ID;
//set the student ID
isTuitionPaid = isTPaid;
//set isTuitionPaid
numberOfCourses = nOfCourses ;
//set the number of courses
for ( int i = 0; i < numberOfCourses; i++) //set the array
{
coursesEnrolled[i].copyCourseInfo(courses[i]);
courseGrades[i] = cGrades[i];
}
sortCourses();
//sort the array coursesEnrolled
}
The definitions of the methods setStudentId , setIsTuitionPaid ,
setNumberOfCourses , and setCoursesEnrolled are similar to the definition of
the method setInfo , and are given next.
1
0
public void setStudentId( int ID)
{
sId = ID;
}
public void setIsTuitionPaid( boolean isTPaid)
{
isTuitionPaid = isTPaid;
}
public void setNumberOfCourses( int nOfCourses)
{
numberOfCourses = nOfCourses ;
}
public void setCoursesEnrolled(Course[] courses,
char [] cGrades)
Search WWH ::




Custom Search