This commit is contained in:
2022-04-21 15:43:38 +08:00
parent 8bb5c66d2c
commit 941b3d26d4
27 changed files with 1525 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
/*
* 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, MajorElective 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);
}
}