-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
49 lines (39 loc) · 1.21 KB
/
Copy pathStudent.java
File metadata and controls
49 lines (39 loc) · 1.21 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Student class
* modified from Savitch's Inheritance Example - Chapter 8 of Java, an Introduction to Problem Solving & Programming
*/
public class Student extends Person
{
private int studentNumber;
public Student( ) {
super();
this.studentNumber = 0;//Indicating no number yet
}
public Student(String initialName) {
super(initialName);
this.studentNumber = 0;//Indicating no number yet
}
public Student(String initialName, int initialStudentNumber) {
super(initialName);
this.studentNumber = initialStudentNumber;
}
public void set(String newName, int newStudentNumber) {
setName(newName);
this.studentNumber = newStudentNumber;
}
public int getStudentNumber( ) {
return this.studentNumber;
}
public void setStudentNumber(int newStudentNumber) {
this.studentNumber = newStudentNumber;
}
public boolean equals(Student otherStudent) {
return (super.equals(otherStudent) &&
this.studentNumber == otherStudent.studentNumber);
}
public String toString( ) {
return(super.toString()
+ "\nStudent number: "
+ this.studentNumber);
}
}