Staff.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * A class representing staff members for a simple BlueJ demo program.
  3. *
  4. * @author Michael Kölling
  5. * @version 1.0, January 1999
  6. */
  7. class Staff extends Person
  8. {
  9. private String room;
  10. /**
  11. * Create a staff member with default settings for detail information.
  12. */
  13. Staff()
  14. {
  15. super("(unknown name)", 0000);
  16. room = "(unknown room)";
  17. }
  18. /**
  19. * Create a staff member with given name, year of birth and room
  20. * number.
  21. */
  22. Staff(String name, int yearOfBirth, String roomNumber)
  23. {
  24. super(name, yearOfBirth);
  25. room = roomNumber;
  26. }
  27. /**
  28. * Set a new room number for this person.
  29. */
  30. public void setRoom(String newRoom)
  31. {
  32. room = newRoom;
  33. }
  34. /**
  35. * Return the room number of this person.
  36. */
  37. public String getRoom()
  38. {
  39. return room;
  40. }
  41. /**
  42. * Return a string representation of this object.
  43. */
  44. public String toString() // redefined from "Person"
  45. {
  46. return super.toString() +
  47. "Staff member\n" +
  48. "Room: " + room + "\n";
  49. }
  50. }