package exo2.entreprise;

import java.util.Map;
import java.util.TreeMap;

/**
 * @author ouziri
 * @version 1.0 
 *
 */

public class Entreprise {
	public Map<String, Service> services = new TreeMap<String, Service>();
	private static int numAutoPersonnel = 1;
	 
	public void setServices(Map<String, Service> services) {
		this.services = services;
	}
	
	// Embauche d'un personnel
	public Personnel embaucherPersonnel (String nom, TypesPersonnelsEnum type, double salaire, String nomService) throws ServiceInexistantException {
		Service service = this.searchServiceByNom(nomService);
		if (service == null)
			throw new ServiceInexistantException (nomService);
		Personnel p = new Personnel(numAutoPersonnel++, nom, type, salaire, service);
		service.personnels.put(numAutoPersonnel, p);
		return p;
	}
	
	// Recherche de services par nom (clé de gestion)
	public Service searchServiceByNom (String nom){
		return this.services.get(nom);
	}	
}
