Page 508 - IT2
P. 508
using System.Collections.Generic;
public class Pilote
{
private string RéfPilote;
private string DésignationPilote;
private List<Composant> Composants_compatibles;
private List<Système> Systèmes_compatibles;
public Pilote(string RéfPilote, string DésignationPilote)
{
this.RéfPilote = RéfPilote;
this.DésignationPilote = DésignationPilote;
Composants_compatibles = new List<Composant>();
Systèmes_compatibles = new List<Système>();
}
public string pRéfPilote
{
get { return RéfPilote; }
set { RéfPilote = value; }
}
public string pDésignationPilote
{
get { return DésignationPilote; }
set { DésignationPilote = value; }
}
public List<Composant> pComposants_compatibles
{
get { return Composants_compatibles; }
set { Composants_compatibles = value; }
}
public List<Système> pSystèmes_compatibles
{
get { return Systèmes_compatibles; }
set { Systèmes_compatibles = value; }
}
public void AjouterComposant(Composant composant)
{
bool existe = false;
foreach (Composant c in Composants_compatibles)
if (c.pRéfComposant == composant.pRéfComposant) existe = true;
if (!existe) Composants_compatibles.Add(composant);
else throw new Exception("Composant existant !");
}
public void AjouterSystème(Système système)
{
bool existe = false;
foreach (Système c in Systèmes_compatibles)
if (c.pRéfSystème == système.pRéfSystème) existe = true;
if (!existe) Systèmes_compatibles.Add(système);
else throw new Exception("Système existant !");
}
public new string ToString()
{
string chaîne = "Composants compatibles:\n";
foreach (Composant c in Composants_compatibles) chaîne += c.ToString() + "\n";
chaîne += "\nSysèmes compatibles:\n";
foreach (Système s in Systèmes_compatibles) chaîne += s.ToString() + "\n";
return RéfPilote + " " + DésignationPilote + ".\n\n" + chaîne ;
}
}
Classe "Produit_Pro"
using System;
using System.Collections.Generic;
public class Produit_Pro : Produit
Filière Epreuve Session 11/13
TDI Synthèse V2(Correction) Juillet 2014

