a4 close #6
This commit is contained in:
56
assignment4/Question5/MajorElective.java
Normal file
56
assignment4/Question5/MajorElective.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user