a4 close #6
This commit is contained in:
45
assignment4/Question4/MajorElective.java
Normal file
45
assignment4/Question4/MajorElective.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user