1 //Create a class for lock device
6 private String displayName
7 private String currentLock
8 private String lockLatestValue
10 locks(int id, String displayName, String currentLock, String lockLatestValue) {
12 this.displayName = displayName
13 this.currentLock = currentLock
14 this.lockLatestValue = lockLatestValue
18 println("the door with id:$id is locked!")
19 this.lockLatestValue = this.currentLock
20 this.currentLock = "locked"
24 println("the door with id:$id is unlocked!")
25 this.lockLatestValue = this.currentLock
26 this.currentLock = "unlocked"
29 def currentValue(String S) {
35 def latestValue(String S) {
37 return lockLatestValue