a4 close #6
This commit is contained in:
46
assignment4/Question4/MajorRequired.java
Normal file
46
assignment4/Question4/MajorRequired.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
||||
* Date: 2022-04-18
|
||||
* Description: This is the MajorRequired class which is used to store the major and required courses.
|
||||
*/
|
||||
|
||||
public class MajorRequired 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 MajorRequired
|
||||
* and cannot be null.
|
||||
*/
|
||||
public MajorRequired(String code, String title, MajorRequired preRequisite) {
|
||||
super(code, title, preRequisite);
|
||||
}
|
||||
|
||||
/**
|
||||
* MajorRequired course is required for all students.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test.
|
||||
*/
|
||||
public static void testMajorRequired() {
|
||||
MajorRequired mr1 = new MajorRequired("COMP3013", "Database Management System", null);
|
||||
System.out.println(mr1.getCode() == null);
|
||||
System.out.println(mr1.getTitle() == null);
|
||||
System.out.println(mr1.getPreRequisite() == null);
|
||||
System.out.println(mr1.isRequired() == true);
|
||||
|
||||
MajorRequired mr2 = new MajorRequired("COMP3013", "Database Management System", mr1);
|
||||
System.out.println(mr2.getCode() == "COMP3013");
|
||||
System.out.println(mr2.getTitle() == "Database Management System");
|
||||
System.out.println(mr2.getPreRequisite() == mr1);
|
||||
System.out.println(mr2.isRequired() == true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user