début TD4

This commit is contained in:
OMGiTzPomPom 2022-10-06 10:41:21 +02:00
parent beeffa4936
commit 61c78c8e14
9 changed files with 154 additions and 2 deletions

View File

@ -2,4 +2,4 @@
//using Programmation_objet_TLESIO21.TD2;
using Programmation_objet_TLESIO21.TD3;
Td3.Launch();
TD4.Launch();

View File

@ -7,7 +7,7 @@ using Programmation_objet_TLESIO21.TD3.fleuriste;
namespace Programmation_objet_TLESIO21.TD3 {
public static class Td3 {
public static class TD4 {
public static void Exo1_1() {
Compte c1 = new Compte();

21
TD4/Collaborateur.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.TD4 {
public class Collaborateur {
private readonly String NOM;
private String DateNaissance;
public Collaborateur(String nom, String birthdate) {
this.NOM = nom;
this.DateNaissance = birthdate;
}
public virtual double getSalaire() {
return .0;
}
}
}

24
TD4/Commercial.cs Normal file
View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.TD4 {
public class Commercial : Collaborateur {
private int SalaireBase;
private int ChiffreAffaire;
private readonly double T2 = 1.1;
public Commercial(String nom, String birthdate, int salaireBase, int chiffreAffaire) : base(nom, birthdate) {
this.SalaireBase = salaireBase;
this.ChiffreAffaire = chiffreAffaire;
}
public override double getSalaire() {
return this.SalaireBase + this.ChiffreAffaire * T2;
}
}
}

32
TD4/Employe.cs Normal file
View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.TD4 {
public class Employe : Collaborateur {
private int TauxHoraire;
private int NbHeures;
private readonly double T1 = 1.1;
public Employe(String nom, String birthdate, int tauxHoraire, int nbHeures) : base(nom, birthdate) {
this.TauxHoraire = tauxHoraire;
this.NbHeures = nbHeures;
}
public override double getSalaire() {
double salaire = 0;
if(this.NbHeures > 35) {
salaire += (this.NbHeures - 35) * this.TauxHoraire * T1;
}
salaire += this.NbHeures * this.TauxHoraire;
return salaire;
}
}
}

26
TD4/Manager.cs Normal file
View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.TD4 {
public class Manager : Collaborateur {
private int SalaireBase;
private int Prime;
public Manager(String nom, String birthdate, int salaireBase, int prime) : base(nom, birthdate) {
this.SalaireBase = salaireBase;
this.Prime = prime;
}
public override double getSalaire() {
return this.SalaireBase + this.Prime;
}
}
}

49
TD4/TD4.cs Normal file
View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Programmation_objet_TLESIO21.TD3.fleuriste;
namespace Programmation_objet_TLESIO21.TD4 {
public static class TD4 {
public static void Exo1() {
TabCollaborateur tab = new TabCollaborateur();
Employe e1 = new Employe("Lejaune", "13051956", 20, 30);
Employe e2 = new Employe("LeBlanc", "20051970", 15, 100);
Manager m1 = new Manager("LeRouge", "14011998", 2500, 150);
Manager m2 = new Manager("LeVert", "29101987", 3000, 200);
Commercial c1 = new Commercial("LeNoir", "29011987", 4000, 30000);
Commercial c2 = new Commercial("LeViolet", "29011987", 3000, 30000);
tab.Add(c1);
tab.Add(e1);
tab.Add(m1);
tab.Add(e2);
tab.Add(m2);
tab.Add(c2);
Console.WriteLine("COLLABORATEUR AYANT PLUS HAUT SALAIRE");
Console.WriteLine(tab.PlusHautSal());
Console.WriteLine("EMPLOYE AYANT PLUS HAUT SALAIRE");
Console.WriteLine(tab.PlusHautSal("Employe"));
Console.WriteLine("MANAGER AYANT PLUS HAUT SALAIRE");
Console.WriteLine(tab.PlusHautSal("Manager"));
Console.WriteLine("COMMERCIAL AYANT PLUS HAUT SALAIRE");
Console.WriteLine(tab.PlusHautSal("Commercial"));
Console.WriteLine("TRI SUR AGE ");
tab.Sort();
foreach(Collaborateur c in tab)
Console.WriteLine(c);
Console.WriteLine("TRI SUR SALAIRE ");
tab.Sort(new TriSalaire());
foreach(Collaborateur c in tab)
Console.WriteLine(c)
}
public static void Launch() {
}
}
}

BIN
pdf/CM/Cours4C#.pdf Normal file

Binary file not shown.

BIN
pdf/TD/TD4.pdf Normal file

Binary file not shown.