forked from line/line-bot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathSubject.java
More file actions
46 lines (36 loc) · 858 Bytes
/
Subject.java
File metadata and controls
46 lines (36 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package skeleton;
import java.util.ArrayList;
import java.util.List;
public class Subject {
private List<Observer> observers;
private String message;
private boolean changed;
public Subject() {
observers = new ArrayList<Observer>();
message = null;
changed = false;
}
public void register(Observer obj) {
if ( !observers.contains(obj) ) observers.add(obj);
}
public void unregister(Observer obj) {
observers.remove(obj);
}
public void notifyObservers() {
// TODO: notify every observers
}
public void setMessage(String msg) {
this.message=msg;
this.changed=true;
notifyObservers();
}
public String getMessage() {
return message;
}
public void setChanged(boolean changed) {
this.changed = changed;
}
public List<Observer> getQueue() {
return observers;
}
}