Java Reference
In-Depth Information
keep track of a student's information from the
class
Person
, and one member of the
class
Student
is of type
Course
. We can add more members as needed.
The basic operations to be performed on an object of type
Student
are as follows:
1. Set the student information.
2. Print the student information.
3. Calculate the number of credit hours taken.
4. Calculate the GPA.
5. Calculate the billing amount.
6. Because the grade report will print the courses in ascending order,
sort the courses according to the course number.
Next, we define the members of the
class
Student
.
Instance Variables:
private int
sId;
//variable to store the
//student ID
private int
numberOfCourses;
//variable to store the number
//of courses
private boolean
isTuitionPaid;
//variable to indicate if
//the tuition is paid
private
Course [] coursesEnrolled;
//array to store
//the courses
private char
[] courseGrades;
//array to store the
//course grades
Constructors and Instance Methods:
public void
setInfo(String fName, String lName,
int
ID,
int
nOfCourses,
boolean
isTPaid,
Course[] courses,
char
[] cGrades)
//Method to set a student's information
//Postcondition: The instance variables are set according
//
to the parameters.
public void
setStudentId(
int
ID)
//Method to set a student ID
//Postcondition: sId = ID;
public void
setIsTuitionPaid(
boolean
isTPaid)
//Method to set whether tuition is paid
//Postcondition: isTuitionPaid = isTPaid;
public void
setNumberOfCourses(
int
nOfCourses)
//Method to set number of courses taken
//Postcondition: numberOfCourses = nOfCourses;
Search WWH ::
Custom Search