import java.util.*;
import java.lang.*;
import java.io.*;

// **************************************************************
// **************************************************************

public class ConcreteMediator implements Mediator {
  // instance variables
  ArrayList<Colleague> group;
  String groupName;
  // constructor method
  public ConcreteMediator(String groupName){
    this.group = new ArrayList<Colleague>();
    this.groupName = groupName;
    System.out.println("Starting chat room " + this.groupName);
  }

  // share sent message with all participants
  // in the chat room
  public void shareMessage(String message, Colleague speaker){
    for (Colleague p : group){
      if (p != speaker) p.receiveMessage("To " + p.getName() + " --> " + message);
    }
  }

  // add Participant to chat room
  public void addParticipant(Colleague p){
    group.add(p);
  }

  public String getName(){
    return this.groupName;
  }
}
