示例#1
0
        static void Main(string[] args)
        {
            /*PrivateContact Jean = new PrivateContact("Jean","Robert",0123456789,"*****@*****.**");
            PrivateContact Chris = new PrivateContact("Chris","DS",0494121212,"*****@*****.**",DateTime.Today);

            if (Jean.BirthdayWish())
            {
                System.Console.Write(Jean + " Bon anniversaire!");
                System.Console.Read();
            }

            if (Chris.BirthdayWish())
            {
                System.Console.Write(Chris + " Bon anniversaire!");
                System.Console.Read();
            }*/

            ProfessionalContact André = new ProfessionalContact("André", "VanKe", "Consultant", 0494111111, "André[email protected]");
            ProfessionalContact Mike = new ProfessionalContact("Mike", "Anderlin", "Consultant", 0494222222, "*****@*****.**");
            ProfessionalContact Isa = new ProfessionalContact("Isabelle", "Charlier", "Indépendant", 0494333333, "*****@*****.**");

            Entreprise Microsoft = new Entreprise("Microsoft","Bruxelles");
            Entreprise SAP = new Entreprise("SAP", "Namur");

            André.EntrepriseAdd(Microsoft);
            André.EntrepriseAdd(SAP);
            Mike.EntrepriseAdd(Microsoft);

            List<ProfessionalContact> listPro = new List<ProfessionalContact>();
            listPro.Add(André);
            listPro.Add(Mike);
            listPro.Add(Isa);

            var listInd = from pro in listPro
                          where pro.Profession == "Indépendant"
                          select pro;
            System.Console.Write(listInd.Count() + " indépendant(s)\n");

            var listProMicrosoft = listPro.Where(pro => pro.Profession == "Consultant" && pro.Entreprises.Contains(Microsoft));
            foreach (var pro in listProMicrosoft)
            {
                System.Console.Write(pro);
                System.Console.Write("\n");
            }
            System.Console.Read();
        }
 public void EntrepriseAdd(Entreprise entreprise)
 {
     Entreprises.Add(entreprise);
 }