Mediator Lab 1

Assignment: Enhancing the Chat Room

You have been given a chat room system that uses the Mediator pattern to facilitate communication between users. Your task is to enhance the system by adding the following functionality:

Requirements:

  1. Modify the User class to include a method called receivePrivateMessage() that allows users to receive private messages from other users. The private message should be sent only to the intended recipient and not broadcast to everyone in the chat room.

  2. Test your implementation by creating a chat room, adding multiple users, and simulating both public and private messages between users. Verify that the messages are sent and received correctly.

Note:

  • You can assume that the existing classes (Mediator, ChatRoom, Colleague, and User) are already implemented correctly.

  • You can use the existing code provided in the previous example as a starting point for your implementation.

 

Good luck with your assignment!