fin TD4
This commit is contained in:
parent
61c78c8e14
commit
6c800f4e6f
@ -1,5 +1,6 @@
|
||||
//using Programmation_objet_TLESIO21.TD1;
|
||||
//using Programmation_objet_TLESIO21.TD2;
|
||||
using Programmation_objet_TLESIO21.TD3;
|
||||
//using Programmation_objet_TLESIO21.TD3;
|
||||
using Programmation_objet_TLESIO21.TD4;
|
||||
|
||||
TD4.Launch();
|
||||
|
@ -14,8 +14,20 @@ namespace Programmation_objet_TLESIO21.TD4 {
|
||||
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;
|
||||
}
|
||||
|
||||
public String GetName() {
|
||||
return this.NOM;
|
||||
}
|
||||
|
||||
public int GetAge() {
|
||||
return 2022 - Int32.Parse(this.DateNaissance.Substring(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
|
||||
this.ChiffreAffaire = chiffreAffaire;
|
||||
}
|
||||
|
||||
public override double getSalaire() {
|
||||
public override double GetSalaire() {
|
||||
return this.SalaireBase + this.ChiffreAffaire * T2;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
|
||||
this.NbHeures = nbHeures;
|
||||
}
|
||||
|
||||
public override double getSalaire() {
|
||||
public override double GetSalaire() {
|
||||
double salaire = 0;
|
||||
|
||||
if(this.NbHeures > 35) {
|
||||
|
@ -15,7 +15,7 @@ namespace Programmation_objet_TLESIO21.TD4 {
|
||||
this.Prime = prime;
|
||||
}
|
||||
|
||||
public override double getSalaire() {
|
||||
public override double GetSalaire() {
|
||||
return this.SalaireBase + this.Prime;
|
||||
}
|
||||
|
||||
|
11
TD4/TD4.cs
11
TD4/TD4.cs
@ -32,15 +32,16 @@ namespace Programmation_objet_TLESIO21.TD4 {
|
||||
Console.WriteLine(tab.PlusHautSal("Commercial"));
|
||||
Console.WriteLine("TRI SUR AGE ");
|
||||
tab.Sort();
|
||||
foreach(Collaborateur c in tab)
|
||||
Console.WriteLine(c);
|
||||
foreach(Collaborateur c in tab.GetCollaborateurs())
|
||||
Console.WriteLine(c.ToString());
|
||||
Console.WriteLine("TRI SUR SALAIRE ");
|
||||
tab.Sort(new TriSalaire());
|
||||
foreach(Collaborateur c in tab)
|
||||
Console.WriteLine(c)
|
||||
tab.Sort("salaire");
|
||||
foreach(Collaborateur c in tab.GetCollaborateurs())
|
||||
Console.WriteLine(c);
|
||||
}
|
||||
|
||||
public static void Launch() {
|
||||
Exo1();
|
||||
|
||||
}
|
||||
|
||||
|
50
TD4/TabCollaborateur.cs
Normal file
50
TD4/TabCollaborateur.cs
Normal 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()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user