static void Main(string[] args) { Personne[] societe = new Personne[8]; societe[0] = new Employé("Misu", "Tira", 22, 1_500); societe[1] = new Employé("Chocolat", "Tarte", 26, 1_700); societe[2] = new Employé("Doodle", "Snicker", 18, 1_300); societe[3] = new Employé("Le Bordelais", "Cane", 35, 1_900); societe[4] = new Employé("Brulée", "Crême", 50, 2_000); societe[5] = new Chef("Ancier", "Finn", 22, 2_600, "Comptable"); societe[6] = new Chef("Chocolat", "Macaron", 22, 2_900, "RH"); societe[7] = new Directeur("Auxpommes", "Tarte", 45, 3_400, "PDG", "Okie Co."); for (int i = 0; i < societe.Length; i++) { societe[i].Afficher(); } Console.WriteLine(); Employé temployé = (Employé)societe[0]; //On perd des données; j'irais voir ça après temployé++; societe[0] = temployé; ((Employé)societe[4]).Salaire = 2_200; ((Chef)societe[6]).Service = "Ressources Humaines"; foreach (Personne personne in societe) { Console.WriteLine(Convert.ChangeType(personne, personne.GetType())); } }
static void Main(String[] args) { Personne[] tableauPersonnes = new Personne[8]; tableauPersonnes[0] = new Employé("marc", "durant", 20, 1400); tableauPersonnes[1] = new Employé("laurant", "dupont", 21, 1500); tableauPersonnes[2] = new Employé("jean", "dujardin", 22, 1600); tableauPersonnes[3] = new Employé("antoine", "martial", 23, 1700); tableauPersonnes[4] = new Employé("pierre", "gasly", 24, 1800); tableauPersonnes[5] = new Chef("dubois", "jean", 25, 1900, "manutention"); tableauPersonnes[6] = new Chef("dubois", "laurent", 26, 2000, "manutention"); tableauPersonnes[7] = new Directeur("boss", "the", 26, 5000, "manutention", "PrestaIT"); ++(tableauPersonnes[0]); ((Employé)tableauPersonnes[1]).setSalaire(9800); ((Chef)tableauPersonnes[5]).setService("cartons"); foreach (Personne personne in tableauPersonnes) { personne.Afficher(); } Console.ReadLine(); }