lab 9 close #7

This commit is contained in:
2022-04-23 00:21:33 +08:00
parent 941b3d26d4
commit 0ced996a6e
35 changed files with 1878 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022-04-21
* Description: This is the class of Door.
*/
public class Door {
/**
* Indicator of whether the door is open or not. Default is closed
*/
private boolean isOpen;
/**
* Constructor.
*/
public Door() {
isOpen = false;
}
/**
* Get whether the door is open or not.
*
* @return true if the door is open, false otherwise
*/
public boolean isOpen() {
return isOpen;
}
/**
* Open the door.
*/
public void open() {
isOpen = true;
}
/**
* Close the door.
*/
public void close() {
isOpen = false;
}
/**
* Test.
*/
public static void testDoor() {
Door d = new Door();
System.out.println(d.isOpen() == false);
d.close();
System.out.println(d.isOpen() == false);
d.open();
System.out.println(d.isOpen() == true);
}
}