/*
  * The mediator allows only registered users
  * to communicate each other and post messages
  * successfully. So, the following method
  * checks whether both the sender and receiver
  * are registered users or not.
  */
 public void Send(AbstractFriend fromFriend, AbstractFriend toFriend, string msg)
 {
     /* Verifying whether the sender is a registered user or not. */
     if (participants.Contains(fromFriend))
     {
         /* Verifying whether the receiver is a registered user and he is online.*/
         if (participants.Contains(toFriend) && toFriend.Status == "On")
         {
             Console.WriteLine($"\n[{fromFriend.Name}] posts: {msg}Last message posted {DateTime.Now}");
             System.Threading.Thread.Sleep(1000);
             /*Target receiver will receive this message.*/
             toFriend.ReceiveMessage(fromFriend, msg);
         }
         else
         {
             Console.WriteLine($"\n{fromFriend.Name},at this moment,you cannot send message to {toFriend.Name} because he is either not a registered user or he is currently offline.");
         }
     }
     //Message sender is NOT a registered user.
     else
     {
         Console.WriteLine($"\nAn outsider named {fromFriend.Name} of [{fromFriend.GetType()}] is trying to send a message to {toFriend.Name}.");
     }
 }
 public void ReceiveMessage(AbstractFriend fromFriend, string msg)
 {
     Console.WriteLine($"{this.Name} has received a message from {fromFriend.Name} saying: {msg} ");
 }
 public void SendMessage(AbstractFriend toFriend, string msg)
 {
     mediator.Send(this, toFriend, msg);
 }
 public void Register(AbstractFriend friend)
 {
     participants.Add(friend);
 }