Beispiel #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();
        }
        static void Main(string[] args)
        {
            /*
            PrivateContact pvt1 = new PrivateContact("Jean", "Louis", 123456789, "*****@*****.**");
            PrivateContact pvt2 = new PrivateContact("Jean", "Neige", 987654321, "*****@*****.**", DateTime.Today);
            if (pvt2.BirthdayWish())
            {
                System.Console.Write("Bon anniversaire " + pvt2.ToString());
            }
            */
            ProfessionalContact cons1 = new ProfessionalContact("Jean", "Louis", "Consultant", 645825735, "*****@*****.**");
            ProfessionalContact cons2 = new ProfessionalContact("Jean", "Neige", "Consultant", 641545735, "*****@*****.**");
            ProfessionalContact ind1 = new ProfessionalContact("Jean", "Victor", "Independant", 645824568, "*****@*****.**");

            Enterprise ent1 = new Enterprise("Larian Studio", "Gand");
            Enterprise ent2 = new Enterprise("Sony", "L.A.");

            cons1.AddEnterprise(ent1);
            cons1.AddEnterprise(ent2);

            cons2.AddEnterprise(ent1);

            ind1.AddEnterprise(ent2);

            List<ProfessionalContact> listPro = new List<ProfessionalContact>();
            listPro.Add(cons1);
            listPro.Add(cons2);
            listPro.Add(ind1);

            var listInd = from p in listPro
                          where p.ListEnt.Count() == 1
                          select p;

            System.Console.Write("Nombre d'indépendants : "+listInd.Count()+ "\n");

            var listCons = listPro.Where(p => (p.ListEnt.Count() > 1));

            System.Console.Write("Nombre de consultants : " + listCons.Count() + "\n");

            System.Console.Read();
        }