-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathStudent.java
More file actions
36 lines (29 loc) · 785 Bytes
/
Student.java
File metadata and controls
36 lines (29 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class Student extends Person{
private String myIdNum; // Student Id Number
private double myGPA; // grade point average
// constructor
public Student(String name, int age, String gender,
String idNum, double gpa){
// use the super class' constructor
super(name, age, gender);
// initialize what's new to Student
myIdNum = idNum;
myGPA = gpa;
}
public String getIdNum(){
return myIdNum;
}
public double getGPA(){
return myGPA;
}
public void setIdNum(String idNum){
myIdNum = idNum;
}
public void setGPA(double gpa){
myGPA = gpa;
}
// overrides the toString method in the parent class
public String toString(){
return super.toString() + ", student id: " + myIdNum + ", gpa: " + myGPA;
}
}