package entreprise;

import java.util.Comparator;

/**
 * Compare des employés par leur salaire, par ordre croissant ou décroissant.
 */
public class ComparateurSalaires implements Comparator<Employe> {
  /**
   * true si compare par ordre croissant.
   */
  private final boolean croissant;
  
  public ComparateurSalaires(boolean croissant) {
    this.croissant = croissant;
  }

  @Override
  public int compare(Employe e1, Employe e2) {
    if (e1.getSalaire() > e2.getSalaire()) {
      return croissant ? 1 : -1;
    }
    else {
      return croissant ? -1 : 1;
    }
  }
  
}