-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartel.java
More file actions
44 lines (36 loc) · 999 Bytes
/
Cartel.java
File metadata and controls
44 lines (36 loc) · 999 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
/*
* @author Douglas Wendel
*
* This class is the Cartel class that implements the observer class.
* This class allows the tester to update and return
* the sighting details and location.
*/
package observerdesignpattern;
import java.util.ArrayList;
public class Cartel implements Observer {
Subject cook;
String notes;
ArrayList<Sighting> sightings;
String temp = "";
public Cartel(Subject cook) {
this.cook = cook;
this.sightings = new ArrayList<Sighting>();
cook.registerObserver(this);
}
@Override
public void update(String location, String description) {
// TODO Auto-generated method stub
//sightings.add(new Sighting(location,description));
//sightings.add(location,description);
sightings.add(new Sighting(location,description));
}
@Override
public String getLog() {
// TODO Auto-generated method stub
for(Sighting sighting:sightings) {
temp+=sighting.getLocation();
temp += "("+sighting.getDetails()+")\n";
}
return temp;
}
}