Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public class Enrolment {
  2.  
  3. private List<Session> sessions;
  4.  
  5. public Enrolment() {
  6. this.sessions = new ArrayList<>();
  7. }
  8.  
  9. public addSession(Session session) {
  10. this.sessions.add(session);
  11. }
  12. }
  13.  
  14. public class Session {
  15.  
  16. private int time;
  17.  
  18. public Session(int time) {
  19. this.time = time;
  20. }
  21. }
  22.  
  23. public class Lecture extends Session {
  24.  
  25. private String lecturer;
  26.  
  27. public Lecture(int time, String lecturer) {
  28. super(time);
  29. this.lecturer = lecturer;
  30. }
  31. }
  32.  
  33. public class Tutorial extends Session {
  34.  
  35. private String tutor;
  36.  
  37. public Tutorial(int time, String tutor) {
  38. super(time);
  39. this.tutor = tutor;
  40. }
  41.  
  42. }
  43.  
  44. public class test {
  45. public static void main(String[] args) {
  46. Enrolment newEnrolment = new Enrolment();
  47.  
  48. Lecture morningLec = new Lecture(900, "Dr. Mike");
  49. newEnrolment.addSession(morningLec);
  50.  
  51. Tutorial afternoonTut = new Tutorial(1400, "John Smith");
  52. newEnrolment.addSession(afternoonTut);
  53.  
  54. Lecture middayLec = new Lecture(1200, "Mr. Micheals");
  55. newEnrolment.addSession(middayLec);
  56.  
  57. Tutorial NightTut = new Tutorial(1900, "Harry Pauls");
  58. newEnrolment.addSession(NightTut);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement