Restore
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
|
||||
public abstract class Course {
|
||||
//the Course class should be abstract as it contains abstract method
|
||||
|
||||
//instance variables
|
||||
private String code;
|
||||
private String title;
|
||||
private Course preRequisite;
|
||||
|
||||
//constructor
|
||||
public Course(String code, String title, Course preRequisite) {
|
||||
if(preRequisite != null) {
|
||||
this.code = code;
|
||||
this.title = title;
|
||||
this.preRequisite = preRequisite;
|
||||
}
|
||||
else {
|
||||
System.out.println("pre-requisite course cannot null!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//methods
|
||||
public String getCode() {return this.code;}
|
||||
|
||||
public String getTitle() {return this.title;}
|
||||
|
||||
public Course getPreRequisite() {return this.preRequisite;}
|
||||
|
||||
//isRequired() should be abstract as the course are undefined
|
||||
public abstract boolean isRequired();
|
||||
|
||||
//test
|
||||
public static void testCourse() {
|
||||
// Since we cannot create any Course object, the testCourse method of the Course class must be empty.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
public class Start {
|
||||
public static void main(String[] args) {
|
||||
Course.testCourse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user