Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a chatroom application where multiple users can send messages to a chat room and it is the responsibility of the chat room to show
Consider a chatroom application where multiple users can send messages to a chat room and it is the responsibility of the chat room to show the messages to all users. This is best achieved using the Mediator Pattern which provides a mediator class that handles all the communications between the different classes (or the many objects of the same class) and supports easy maintenance of the code by loose coupling. The class diagram is shown in Fig. Q3. 3. MediatorPatternDemo User ChatRoom uses uses name: String +User(String): void +getName): String +setName(String) void +sendMessage(String): void +showMessage(User, String): void main(): void Fig. Q3 Assume that when the ChatRoom class performs a System.out.println() action, every User is able to see it. Write the Java code for all the three classes shown above. In the main() method, instantiate two users and make each one send a message
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started