a4 close #6
This commit is contained in:
58
assignment4/Question6/Base.java
Normal file
58
assignment4/Question6/Base.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
||||
* Date: 2022-04-18
|
||||
* Description: This is the Base Class.
|
||||
*/
|
||||
|
||||
public class Base implements Learnable {
|
||||
private String code;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param code The code of the course
|
||||
* @param title The title of the course
|
||||
*/
|
||||
public Base(String code, String title) {
|
||||
this.code = code;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of code
|
||||
*
|
||||
* @return The code of the course
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of title
|
||||
*
|
||||
* @return The title of the course
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pre-requisite course. It will return itself.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public Learnable getPreRequisite() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test.
|
||||
*/
|
||||
public static void testBase() {
|
||||
Base base = new Base("COMP3013", "Database Management System");
|
||||
System.out.println(base.getCode() == "COMP3013");
|
||||
System.out.println(base.getTitle() == "Database Management System");
|
||||
System.out.println(base.getPreRequisite() == base);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user