Mediator Design pattern
3 posters
IITDU Forum :: Academics (BIT) :: Semester 5 :: SE 506
Page 1 of 1
Mediator Design pattern
public class Head extends Friend {
public Head(String name) {
super(name);
}
public void receive(String from, String message) {
System.out.println("Head '" + this.getName()
+ "' received a message from '" + from + "': " + message);
}
}
........................................................................
public class Receiver {
public static void main(String args[]) {
Head he = new Head("Asif Imran");
Friend f1 = new Friend("Amit");
Friend f2 = new Friend("Muctadir");
System.out.println("Chat Server");
he.send("Lets play NFS mostwanted");
f1.send("Asif Imran", "I need to do my design pattern home task");
he.send("Amit", "I have not done mine yet, but i want to play");
f2.send("No I want to play urban terror");
}
}
........................................................................................
public interface Connect {
/**
* Retrieve the name of the colleague.
*/
public String getName();
public void send(String to, String message);
public void send(String message);
public void receive(String from, String message);
}
....................................................................................
public class Friend implements Colleague {
private String name;
public Friend(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void send(String to, String message) {
System.out.println("yes'" + this.name + "' is sending a message to '" + to
+ "': " + message);
}
public void send(String message) {
System.out.println("yes'" + this.name + "' is sending a public message: "
+ message);
this.forum.send(this.name, message);
}
public void receive(String from, String message) {
System.out.println("Hello, '" + this.name
+ "' received a message from '" + from + "': " + message);
}
}
public Head(String name) {
super(name);
}
public void receive(String from, String message) {
System.out.println("Head '" + this.getName()
+ "' received a message from '" + from + "': " + message);
}
}
........................................................................
public class Receiver {
public static void main(String args[]) {
Head he = new Head("Asif Imran");
Friend f1 = new Friend("Amit");
Friend f2 = new Friend("Muctadir");
System.out.println("Chat Server");
he.send("Lets play NFS mostwanted");
f1.send("Asif Imran", "I need to do my design pattern home task");
he.send("Amit", "I have not done mine yet, but i want to play");
f2.send("No I want to play urban terror");
}
}
........................................................................................
public interface Connect {
/**
* Retrieve the name of the colleague.
*/
public String getName();
public void send(String to, String message);
public void send(String message);
public void receive(String from, String message);
}
....................................................................................
public class Friend implements Colleague {
private String name;
public Friend(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void send(String to, String message) {
System.out.println("yes'" + this.name + "' is sending a message to '" + to
+ "': " + message);
}
public void send(String message) {
System.out.println("yes'" + this.name + "' is sending a public message: "
+ message);
this.forum.send(this.name, message);
}
public void receive(String from, String message) {
System.out.println("Hello, '" + this.name
+ "' received a message from '" + from + "': " + message);
}
}
BIT0119-Asif- Study Moderator
- Course(s) :
- BIT
Blood Group : B+
Posts : 163
Points : 432
Re: Mediator Design pattern
খাইছে!! আসিফ নাকি!!
দোস্ত, কোডটা কোড ট্যাগ ব্যবহার করে দাও একটু কষ্ট করে। আর আলাদা আলাদা করে কোড ট্যাগ ব্যবহার করলে পড়তে সুবিধা। নাহলে বার বার গুলায়ে যাচ্ছে।
দোস্ত, কোডটা কোড ট্যাগ ব্যবহার করে দাও একটু কষ্ট করে। আর আলাদা আলাদা করে কোড ট্যাগ ব্যবহার করলে পড়তে সুবিধা। নাহলে বার বার গুলায়ে যাচ্ছে।
Re: Mediator Design pattern
এখানে দুইজন লোককে তেল দেওয়া হয়েছে.....
BIT0111-muctadir- Expert
- Course(s) :
- BIT
Blood Group : B+
Posts : 233
Points : 395
Re: Mediator Design pattern
ঘন্টার তেল। ব্যাটা আমাদের ফাকিবাজ হিসেবে চিত্রায়িত করেছে।
ভালো করে দেখ। আমাদের দেখাচ্ছে আমরা তার পড়াশুনায় ব্যাঘাত করছি।
ওরে যদি আর খেলায় নিছি....
ভালো করে দেখ। আমাদের দেখাচ্ছে আমরা তার পড়াশুনায় ব্যাঘাত করছি।
ওরে যদি আর খেলায় নিছি....
Similar topics
» Design Pattern study material: Composite Pattern
» Design pattern Assignment - fly weight pattern
» Design Pattern: Assignment Shapes
» Shapes Design using Composite pattern
» Design Pattern : Smelly Code help material
» Design pattern Assignment - fly weight pattern
» Design Pattern: Assignment Shapes
» Shapes Design using Composite pattern
» Design Pattern : Smelly Code help material
IITDU Forum :: Academics (BIT) :: Semester 5 :: SE 506
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford