Page 507 - IT2
P. 507

{
            this.RéfProduit = RéfProduit;
            this.DésignationProduit = DésignationProduit;
            this.système = système;
            Composants_intégrés = new List<Intégration>();
        }

        public string pRéfProduit
        {
            get { return RéfProduit; }
            set { RéfProduit = value; }
        }

        public string pDésignationProduit
        {
            get { return DésignationProduit; }
            set { DésignationProduit = value; }
        }

        public float pPrixProduit
        {
            get { return PrixProduit; }
        }

        public Système psystème
        {
            get { return système; }
            set { système = value; }
        }

        public List<Intégration> pComposants_intégrés
        {
            get { return Composants_intégrés; }
            set { Composants_intégrés = value; }
        }

        public void IntégrerComposant(Intégration composant_intégré)
        {
            bool existe = false;
            foreach (Intégration ci in Composants_intégrés)
               if (ci.pComposantIntégré.pRéfComposant == composant_intégré.pComposantIntégré.pRéfComposant) existe = true;
            if (!existe) Composants_intégrés.Add(composant_intégré);
            else throw new Exception("Composant déjà intégré !");

        }

        public void EnleverComposant(string référence_composant)
        {
            bool existe = false;
            foreach (Intégration ci in Composants_intégrés)
                if (ci.pComposantIntégré.pRéfComposant == référence_composant)
                { existe = true; Composants_intégrés.Remove(ci); break; }
            if (!existe) throw new Exception("Référence Composant inexistante !");

        }

        public virtual void CalculerPrix()
        {
            foreach (Intégration ci in Composants_intégrés)
                PrixProduit+=ci.pComposantIntégré.pPrixComposant * ci.pQuantitéIntegrée;
            PrixProduit += système.pPrixSystème;
            PrixProduit *= 1.2F;
        }

        public new virtual string ToString()
        {
            string chaîne = "";
            foreach (Intégration ci in Composants_intégrés) chaîne += ci.ToString() + "\n";
        return RéfProduit + " " + DésignationProduit + " " + PrixProduit + " DH.\n" + chaîne + système.ToString() + "\n" ;
        }
    }

                            Classe "Pilote"


    using System;

                     Filière                    Epreuve                        Session             10/13
                      TDI                 Synthèse V2(Correction)            Juillet 2014
   502   503   504   505   506   507   508   509   510   511   512