MCPcopy Index your code
hub / github.com/Seogeurim/CS-study / Netflix

Class Netflix

contents/design-pattern/code/ObserverJava/Netflix.java:4–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3
4public class Netflix implements Observable {
5 ArrayList<NetflixUser> userList;
6
7 public Netflix() {
8 this.userList = new ArrayList<NetflixUser>();
9 }
10
11 public void updateMovie(String movie){
12 notifyMovie(movie);
13 }
14
15 public void updateAnimation(String animation){
16 notifyAnimation(animation);
17 }
18
19 @Override
20 public synchronized void addObserver(NetflixUser user) {
21 System.out.println(user.name + "가 Netflix를 구독하기 시작했습니다.");
22 userList.add(user);
23 }
24
25 @Override
26 public synchronized void deleteObserver(NetflixUser user) {
27 System.out.println(user.name + "가 Netflix를 구독 취소했습니다.");
28 userList.remove(user);
29 }
30
31 @Override
32 public void notifyMovie(String content) {
33 for (NetflixUser user : userList) {
34 user.updateMovie(content);
35 }
36 }
37
38 @Override
39 public void notifyAnimation(String content) {
40 for (NetflixUser user : userList) {
41 user.updateAnimation(content);
42 }
43 }
44
45
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected