123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * A class representing students for a simple BlueJ demo program.
  3. *
  4. * @author Michael Kölling
  5. * @version 1.0, January 1999
  6. */
  7. class Student extends Person
  8. {
  9. private String SID; // student ID number
  10. /**
  11. * Create a student with default settings for detail information.
  12. */
  13. public Student()
  14. {
  15. super("(unknown name)", 0000);
  16. SID = "(unknown ID)";
  17. }
  18. /**
  19. * Create a student with given name, year of birth and student ID
  20. */
  21. public Student(String name, int yearOfBirth, String studentID)
  22. {
  23. super(name, yearOfBirth);
  24. SID = studentID;
  25. }
  26. /**
  27. * Return the stident ID of this student.
  28. */
  29. public String getStudentID()
  30. {
  31. return SID;
  32. }
  33. /**
  34. * Return a string representation of this object.
  35. */
  36. public String toString() // redefined from "Person"
  37. {
  38. return super.toString() +
  39. "Student\n" +
  40. "Student ID: " + SID + "\n";
  41. }
  42. }