Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Enrolment {
- private List<Session> sessions;
- public Enrolment() {
- this.sessions = new ArrayList<>();
- }
- public addSession(Session session) {
- this.sessions.add(session);
- }
- }
- public class Session {
- private int time;
- public Session(int time) {
- this.time = time;
- }
- }
- public class Lecture extends Session {
- private String lecturer;
- public Lecture(int time, String lecturer) {
- super(time);
- this.lecturer = lecturer;
- }
- }
- public class Tutorial extends Session {
- private String tutor;
- public Tutorial(int time, String tutor) {
- super(time);
- this.tutor = tutor;
- }
- }
- public class test {
- public static void main(String[] args) {
- Enrolment newEnrolment = new Enrolment();
- Lecture morningLec = new Lecture(900, "Dr. Mike");
- newEnrolment.addSession(morningLec);
- Tutorial afternoonTut = new Tutorial(1400, "John Smith");
- newEnrolment.addSession(afternoonTut);
- Lecture middayLec = new Lecture(1200, "Mr. Micheals");
- newEnrolment.addSession(middayLec);
- Tutorial NightTut = new Tutorial(1900, "Harry Pauls");
- newEnrolment.addSession(NightTut);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement