This commit is contained in:
OMGiTzPomPom 2022-10-11 10:04:27 +02:00
parent 61c78c8e14
commit 6c800f4e6f
7 changed files with 74 additions and 10 deletions

View File

@ -1,5 +1,6 @@
//using Programmation_objet_TLESIO21.TD1; //using Programmation_objet_TLESIO21.TD1;
//using Programmation_objet_TLESIO21.TD2; //using Programmation_objet_TLESIO21.TD2;
using Programmation_objet_TLESIO21.TD3; //using Programmation_objet_TLESIO21.TD3;
using Programmation_objet_TLESIO21.TD4;
TD4.Launch(); TD4.Launch();

View File

@ -14,8 +14,20 @@ namespace Programmation_objet_TLESIO21.TD4 {
this.DateNaissance = birthdate; this.DateNaissance = birthdate;
} }
public virtual double getSalaire() { public override string ToString() {
return this.NOM + " - Age " + this.GetAge() + " - Salaire " + this.GetSalaire();
}
public virtual double GetSalaire() {
return .0; return .0;
} }
public String GetName() {
return this.NOM;
}
public int GetAge() {
return 2022 - Int32.Parse(this.DateNaissance.Substring(4));
}
} }
} }

View File

@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
this.ChiffreAffaire = chiffreAffaire; this.ChiffreAffaire = chiffreAffaire;
} }
public override double getSalaire() { public override double GetSalaire() {
return this.SalaireBase + this.ChiffreAffaire * T2; return this.SalaireBase + this.ChiffreAffaire * T2;
} }

View File

@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
this.NbHeures = nbHeures; this.NbHeures = nbHeures;
} }
public override double getSalaire() { public override double GetSalaire() {
double salaire = 0; double salaire = 0;
if(this.NbHeures > 35) { if(this.NbHeures > 35) {

View File

@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
this.Prime = prime; this.Prime = prime;
} }
public override double getSalaire() { public override double GetSalaire() {
return this.SalaireBase + this.Prime; return this.SalaireBase + this.Prime;
} }

View File

@ -32,15 +32,16 @@ namespace Programmation_objet_TLESIO21.TD4 {
Console.WriteLine(tab.PlusHautSal("Commercial")); Console.WriteLine(tab.PlusHautSal("Commercial"));
Console.WriteLine("TRI SUR AGE "); Console.WriteLine("TRI SUR AGE ");
tab.Sort(); tab.Sort();
foreach(Collaborateur c in tab) foreach(Collaborateur c in tab.GetCollaborateurs())
Console.WriteLine(c); Console.WriteLine(c.ToString());
Console.WriteLine("TRI SUR SALAIRE "); Console.WriteLine("TRI SUR SALAIRE ");
tab.Sort(new TriSalaire()); tab.Sort("salaire");
foreach(Collaborateur c in tab) foreach(Collaborateur c in tab.GetCollaborateurs())
Console.WriteLine(c) Console.WriteLine(c);
} }
public static void Launch() { public static void Launch() {
Exo1();
} }

50
TD4/TabCollaborateur.cs Normal file
View File

@ -0,0 +1,50 @@
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()));
}
}
}
}