/** Class for a student. */
public class Student implements Person {
String id;
String name;
int age;
/** Constructor. */
public Student (String i, String n, int a) {
id = i;
name = n;
age = a;
}
/** Number of hours spent studying weekly */
protected int studyHours() {
return age/2; // guessing it is proportional to the age
}
//** ID of the student. */
public String getID () {
return id;
}
// The next three methods are for implementing the Person interface.
public String getName() {
return name;
}
public int getAge() {
return age;
}
public boolean equalTo (Person other) {
Student otherStudent = (Student) other; // cast Person to Student
return (id.equals (otherStudent.getID())); // compare IDs
}
}