51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Runtime.CompilerServices;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Programmation_objet_TLESIO21.TD4 {
|
|||
|
public class TabCollaborateur {
|
|||
|
private List<Collaborateur> collaborateurs;
|
|||
|
|
|||
|
public TabCollaborateur() {
|
|||
|
this.collaborateurs = new List<Collaborateur>();
|
|||
|
}
|
|||
|
|
|||
|
public void Add(Collaborateur collaborateur) {
|
|||
|
this.collaborateurs.Add(collaborateur);
|
|||
|
}
|
|||
|
|
|||
|
public List<Collaborateur> GetCollaborateurs() {
|
|||
|
return this.collaborateurs;
|
|||
|
}
|
|||
|
|
|||
|
public String PlusHautSal(String t = "") {
|
|||
|
String n = "";
|
|||
|
double sal = .0;
|
|||
|
foreach(Collaborateur c in this.collaborateurs) {
|
|||
|
|
|||
|
String tempT = c.GetType().ToString().Split(".")[2];
|
|||
|
if(t.Equals("") || t.Equals(tempT)) {
|
|||
|
if(c.GetSalaire() > sal) {
|
|||
|
n = c.GetName();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return n;
|
|||
|
}
|
|||
|
|
|||
|
public void Sort(String type = "") {
|
|||
|
if(type.Equals("")) {
|
|||
|
this.collaborateurs.Sort((a,b) => a.GetAge().CompareTo(b.GetAge()));
|
|||
|
}
|
|||
|
|
|||
|
if(type.Equals("salaire")) {
|
|||
|
this.collaborateurs.Sort((a, b) => a.GetSalaire().CompareTo(b.GetSalaire()));
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|