57 lines
1.8 KiB
Java
57 lines
1.8 KiB
Java
/*
|
|
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
|
* Date: 2022-04-18
|
|
* Description: This is the MajorElective class which is elective for students.
|
|
*/
|
|
|
|
public class MajorElective extends Course {
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param code The code of the course.
|
|
* @param title The title of the course.
|
|
* @param preRequisite The pre-requisite of the course. Type of MajorElective
|
|
* and cannot be null.
|
|
*/
|
|
public MajorElective(String code, String title, Learnable preRequisite) {
|
|
super(code, title, preRequisite);
|
|
}
|
|
|
|
/**
|
|
* MajorRequired course is elective for all students.
|
|
*
|
|
* @return false
|
|
*/
|
|
public boolean isRequired() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Test.
|
|
*/
|
|
public static void testMajorElective() {
|
|
MajorElective pre = new MajorElective("CSC108", "Intro to Programming", null);
|
|
System.out.println(pre.getCode() == null);
|
|
System.out.println(pre.getTitle() == null);
|
|
System.out.println(pre.getPreRequisite() == null);
|
|
System.out.println(pre.isRequired() == false);
|
|
|
|
MajorElective pre2 = new MajorElective("CSC108", "Intro to Programming", pre);
|
|
System.out.println(pre2.getCode() == "CSC108");
|
|
System.out.println(pre2.getTitle() == "Intro to Programming");
|
|
System.out.println(pre2.getPreRequisite() == pre);
|
|
System.out.println(pre2.isRequired() == false);
|
|
|
|
Base base = new Base("COMP4023", "Software Engineering");
|
|
System.out.println(base.getCode() == "COMP4023");
|
|
System.out.println(base.getTitle() == "Software Engineering");
|
|
System.out.println(base.getPreRequisite() == base);
|
|
|
|
MajorElective me = new MajorElective("CSC123", "Big Data", base);
|
|
System.out.println(me.getCode() == "CSC123");
|
|
System.out.println(me.getTitle() == "Big Data");
|
|
System.out.println(me.getPreRequisite() == base);
|
|
System.out.println(me.isRequired() == false);
|
|
}
|
|
}
|