-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubject.java
More file actions
40 lines (32 loc) · 847 Bytes
/
Copy pathSubject.java
File metadata and controls
40 lines (32 loc) · 847 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
//package AuctionHouse;
import java.util.ArrayList;
import java.util.List;
public class Subject {
private List<Observer> observers = new ArrayList<Observer>();
private int amount;
private String username;
private String description;
public String getDescription() {
return description;
}
public int getAmount() {
return amount;
}
public String getUsername() {
return username;
}
public void setState(int amount,String username,String description) {
this.amount = amount;
this.username=username;
this.description=description;
notifyAllObservers();
}
public void attach(Observer observer){
observers.add(observer);
}
public void notifyAllObservers(){
for (Observer observer : observers) {
observer.update();
}
}
}