Page 509 - IT2
P. 509
{
private sbyte garantie;
private DateTime date_début_garantie;
public Produit_Pro(string RéfProduit, string DésignationProduit, Système système, sbyte garantie, DateTime
date_début_garantie) : base(RéfProduit, DésignationProduit, système)
{
pgarantie = garantie;
this.date_début_garantie = date_début_garantie;
}
public sbyte pgarantie
{
get { return garantie; }
set
{
if (value > 1 && value <= 5) garantie = value;
else throw new Exception("Garantie invalide !");
}
}
public DateTime pdate_début_garantie
{
get { return date_début_garantie; }
set { date_début_garantie = value; }
}
public override void CalculerPrix()
{
base.CalculerPrix();
base.PrixProduit += 750F * garantie;
}
public DateTime Fin_garantie()
{
return date_début_garantie.AddYears(garantie);
}
public void Etendre_garantie(sbyte nombre_années)
{
pgarantie = (sbyte) (garantie + nombre_années);
}
public override string ToString()
{
return base.ToString() + "Garantie: " + garantie + " ans de " + date_début_garantie.ToShortDateString() + " à
" + Fin_garantie().ToShortDateString() + ".";
}
}
Filière Epreuve Session 12/13
TDI Synthèse V2(Correction) Juillet 2014

