-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
38 lines (36 loc) · 746 Bytes
/
Student.java
File metadata and controls
38 lines (36 loc) · 746 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
37
38
public class Student extends Person //Extends is inheritance or "is a"
{
private int id;
public Student()
{
super(); //Call to the Person's default constructor
this.id = 0;
}
public Student(String aName, int aID)
{
super(aName); //Call to person's parameterized constructor
//TODO Call Mutators
this.setID(aID);
}
public int getID()
{
return this.id;
}
public void setID(int aID)
{
if(aID >= 0)
{
this.id = aID;
}
}
public String toString() //Overriding
{
return super.toString()+"\nID: "+this.id;
}
public boolean equals(Student aStudent)
{
return aStudent != null &&
super.equals(aStudent) && //Student is a person too
this.id == aStudent.getID();
}
}