Question: help me i am working on observer design pattern i want that kindly draw a complete class diagram for the following code that i paste

help me i am working on observer design pattern i want that kindly draw a complete class diagram for the following code that i paste below

if you have any query feel free to ask i have limited time

i have three classes youtubee (main) , channel , subscriber

import java .util.ArrayList; import java .util.List;

public class Channel implements Subject { List subs = new ArrayList<>(); String title; @Override public void subscribe(Subcriber sub) { subs.add(sub); } @Override public void unsubscribe(Subcriber sub) { subs.remove(sub); } @Override public void notifysubscribers() { for(Subcriber sub : subs) { sub.update(); } } @Override public void upload(String title) { this.title = title; notifysubscribers(); }

}

\\Subscriber class

public class Subcriber implements Observer { private String name; private Channel Channel = new Channel();

public Subcriber(String name) { super(); this.name = name; }

@Override public void update() { System.out.println("Hey " + name + " video uploaded: " + Channel.title); } @Override public void subscribeChannel(Channel ch) { Channel = ch; } }

// youtubeee class

public class Youtubeee { public static void main(String[] args) { Channel learn_programming = new Channel(); Subcriber s1 = new Subcriber("jerry"); Subcriber s2 = new Subcriber("john"); Subcriber s3 = new Subcriber("tom"); learn_programming.subscribe(s1); learn_programming.subscribe(s2); learn_programming.subscribe(s3); learn_programming.unsubscribe(s3); s1.subscribeChannel(learn_programming); s2.subscribeChannel(learn_programming); s3.subscribeChannel(learn_programming); learn_programming.upload("How to learn programming?");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!