static void Main(string[] args) { Employe employe1 = new Employe("Robert", "Jorge", 34, 2400); Employe employe2 = new Employe("George", "Lucas", 55, 3000); Employe employe3 = new Employe("Pas di caprio", "Leonardo", 39, 2900); Employe employe4 = new Employe("Earthwalker", "Luke", 27, 2600); Employe employe5 = new Employe("Multiple", "Han", 45, 3700); Chef chef1 = new Chef("McCain", "John", 49, 5700, "General"); Chef chef2 = new Chef("McDonald", "David", 49, 5700, "Informatique"); Directeur directeur = new Directeur("Philip", "Michael", 65, 75000, "General", "CsharpCorporation"); Personne[] societeTableau = new Personne[] { employe1, employe2, employe3, employe4, employe5, chef1, chef2, directeur }; for (int i = 0; i < societeTableau.Length; i++) { societeTableau[i].Afficher(); } Employe Emp1 = (Employe)societeTableau[3]; Emp1.SetAge()++; societeTableau[2] = Emp1; Employe tempEmp = (Employe)societeTableau[2]; tempEmp.Salaire = 1200; societeTableau[2] = tempEmp; Chef tempChef = (Chef)societeTableau[5]; tempChef.Service = "Ressources humaines"; societeTableau[5] = tempChef; foreach (Personne p in societeTableau) { p.Afficher(); } }
static void Main(string[] args) { Employe e1 = new Employe("Kirigaya", "Kazuto", 17, 2000); Employe e2 = new Employe("Yuki", "Asuna", 18, 2000); Employe e3 = new Employe("Synthesis Thirty", "Alice", 19, 2000); Employe e4 = new Employe("Knight", "Eugeo", 19, 2000); Employe e5 = new Employe("Kirigaya", "Suguha", 17, 2000); Chef c1 = new Chef("Koujiro", "Rinko", 28, 5000, "RATH"); Chef c2 = new Chef("Kikuoka", "Kikuoka", 30, 5000, "RATH"); Directeur d1 = new Directeur("Akihiko", "Kayaba", 30, 7000, "IA", "THE SEED"); List <Personne> personneList = new List <Personne>() { e1, e2, e3, e4, e5, c1, c2, d1 }; for (int i = 0; i <= personneList.Count - 1; i++) { personneList[i].Afficher(); } personneList[0]++; c1.Salaire += 500; c2.Service = "DEFENSE"; foreach (var personne in personneList) { personne.Afficher(); } Console.ReadKey(); }
public static void Main(string[] args) { var emp1 = new Employe("jean", "michel", 44, 1900.50); var emp2 = new Employe("jean", "patrick", 24, 1500); var emp3 = new Employe("jean", "moulin", 34, 1500); var emp4 = new Employe("jean", "claude", 54, 1500); var emp5 = new Employe("jean", "marie", 14, 1500); var chef1 = new Chef("marie", "christine", 44, 2300, "RH"); var chef2 = new Chef("marie", "therese", 44, 2300, "DSI"); var dir1 = new Directeur("anne", "lise", 44, 2300, "ELITE", "Leclerc"); dir1.Afficher(); chef2.Afficher(); emp3.Afficher(); Personne[] personnesArray = new Personne[8]; personnesArray[0] = emp1; personnesArray[1] = emp2; personnesArray[2] = emp3; personnesArray[3] = emp4; personnesArray[4] = emp5; personnesArray[5] = chef1; personnesArray[6] = chef2; personnesArray[7] = dir1; for (int i = 0; i < personnesArray.Length; i++) { personnesArray[i].Afficher(); } emp1++; emp2.Salaire = 1600; chef1.Service = "DRH"; for (int i = 0; i < personnesArray.Length; i++) { personnesArray[i].Afficher(); } }
static void Main(string[] args) { var employe1 = new Employe("Liane", "Beaujolie", 18, 1000); var employe2 = new Employe("Onfroi ", "Baron", 22, 2000); var employe3 = new Employe("Orlene ", "Ratté", 1500); var employe4 = new Employe("Felicien ", "Cinq-Mars", 26, 1250); var employe5 = new Employe("Madeleine ", "Leclair", 1900); var chef1 = new Chef("Édith", "Camus", 3000, "Informatique"); var chef2 = new Chef("Solaine", "Laframboise", 45, 3000, "Informatique"); var directeur = new Directeur("Somerville", "Marquis", 4000, "Direction", "Facebook"); var tableauArticle = new[] { employe1, employe2, employe3, employe4, employe5, chef1, chef2, directeur }; Console.WriteLine("[Parcours de tous les employés avec FOR]"); for (int i = 0; i < tableauArticle.Length; i++) { tableauArticle[i].Afficher(); Console.WriteLine(Environment.NewLine); } employe2.Age++; chef1.Salaire = 3500; chef1.Service = "Comptable"; Console.WriteLine("[Parcours de tous les employés avec FOREACH]"); foreach (var employe in tableauArticle) { employe.Afficher(); Console.WriteLine(Environment.NewLine); } }