Example #1
0
 public void TestMethod2()
 {           
     Pupil p = new Pupil("Toto", 10);
     
     var evaluation = p.GetEvatuation("env dev");
     Assert.AreEqual('d', evaluation);
 }
Example #2
0
 public void TestMethod1()
 {//AAA
     //1. Arrange => on instancie
     Pupil p = new Pupil("Toto", 10);
     //2. Act =W on utilise le system
     p.AddEvaluation("env dev", 'd');
     //3. Assert => on compare résultat obtenu et attendu
     var evaluation = p.GetEvatuation("env dev");
     Assert.AreEqual('d', evaluation);
 }
Example #3
0
        static void Main(string[] args)
        {
            Pupil pupil1 = new Pupil("Aurelie", 6, 1);

            Activity coloriage = new Activity("Coloriage", true);
            pupil1.AddActivity(coloriage);
            pupil1.AddEvaluation("Coloriage");
            pupil1.AddEvaluation(evaluation: 'T', title: " Coloriage");

            //List<Pupil> lstPupil = new List<Pupil>()
            //{
            //     new Pupil("Antoine", 7, 1),
            //     new Pupil("Marc",9, 4),
            //     new Pupil("Marine",8, 3),
            //     new Pupil("Henri", 7, 1),
            //     new Pupil("Amelie", 10, 5),
            //     new Pupil("Anna", 6, 1),
            //     new Pupil("Lena", 7, 2),
            //     new Pupil("George", 6, 1),
            //     new Pupil("Albert", 6, 1),
            //     new Pupil("kate", 8, 3),
            //     new Pupil("Charles", 7, 3),
            //     new Pupil("Henri", 6, 1),
            //     new Pupil("Marcelle",10, 4),
            //};

            //var pupilGrade1Plus6 = from Pupil in lstPupil
            //                       where Pupil.Age > 6 && Pupil.Grade == 1
            //                       select Pupil;

            //Expression lambda
            //var pupilGrade1Plus6 = lstPupil.Where(Pupil => Pupil.Age > 6 && Pupil.Grade == 1);

            //if (pupilGrade1Plus6 != null )
            //{
            //    foreach ( var Pupil in pupilGrade1Plus6 )
            //    {
            //        System.Console.Write(Pupil);
            //    }
            //}

                 // COVARIANCE
            //List<Pupil> listPupils = new List<Pupil>()
            //{
            //    new Pupil("Marc",19,2),
            //    new Pupil("Albert",20,2),
            //    new Pupil("Marie",21,3),
            //    new Pupil("Luca",18,1),
            //    new Pupil("jean",19,1),
            //    new Pupil("Charles",21,3),
            //};

            //List<Person> listPersons = new List<Person>()
            //{
            //    new Person("Marc",19),
            //    new Person("Albert",20),
            //    new Person("Marie",21),
            //    new Person("Luca",18),
            //    new Person("jean",19),
            //    new Person("Charles",21),
            //};

            //var listFusion = listPersons.Union(listPupils);
            //if (listFusion != null)
            //{
            //    foreach (var Person in listFusion )
            //    {
            //        System.Console.Write(Person);
            //    }
            //}

            List<Pupil> listPupilsDuplicated = new List<Pupil>()
            {
                new Pupil("Marc",19,2),
                new Pupil("Marc",19,1),
                new Pupil("Albert",20,3),
                new Pupil("Albert",20,2),
                new Pupil("Marie",21,1),
                new Pupil("Marie",21,3),
                new Pupil("Luca",18,2),
                new Pupil("Luca",18,1),
                new Pupil("jean",19,3),
                new Pupil("jean",19,1),
            };
            IEnumerable<Pupil> listPupilsNoDuplicated = listPupilsDuplicated.Distinct<Pupil>(
                new PersonComparer());

            System.Console.Write(listPupilsNoDuplicated.Count());

               // Pupil pupil1 = new Pupil("Jean", 8, 'T');
               // pupil1.AddActivity(activity3);
            //Activity activity2 = new Activity("Danse", false);
            //Activity activity3 = new Activity("Sport", true);
            //System.Console.Write(pupil2);

            //System.Console.Write(pupil1);

            System.Console.Read();
        }
Example #4
0
        static void Main(string[] args)
        {
            Pupil allesandro = new Pupil("Alessandro", 5);
            Pupil thais      = new Pupil("Thaïs", 7, 2);
            Pupil thais2     = new Pupil("Thaïs", 8, 2);
            Pupil machin2    = new Pupil("machin", 7, 2);

            Pupil Machin = new Pupil("Machin", 8);
            Pupil Truc   = new Pupil("Truc", 10);
            Pupil Idiot  = new Pupil("Idiot", 15);

            List <Pupil> pupils = new List <Pupil>();

            pupils.Add(allesandro);
            pupils.Add(thais);
            pupils.Add(Machin);
            pupils.Add(Truc);
            pupils.Add(Idiot);
            pupils.Add(thais2);
            pupils.Add(machin2);

            List <Person> persons = new List <Person>()
            {
                new Person("Matthieu", 23),
                new Person("Olivier", 22),
                new Person("Vassili", 10)
            };
            Activity calculus = new Activity("Calcul", true);
            Activity french   = new Activity("Français", true);
            Activity english  = new Activity("Anglais");
            Activity religion = new Activity("Religion");
            Activity sport    = new Activity("Sport", true);

            allesandro.AddActivity(calculus);
            allesandro.AddActivity(french);
            allesandro.AddActivity(sport);
            allesandro.AddActivity(english);
            allesandro.AddEvaluation("Français", 'B');
            allesandro.AddEvaluation("Sport", 'B');

            thais.AddActivity(calculus);
            thais.AddActivity(french);
            thais.AddActivity(religion);
            thais.AddActivity(sport);
            thais.AddEvaluation("Religion", 'S');
            thais.AddEvaluation("Licornes", 'T');
            System.Console.WriteLine(allesandro.ToString());
            System.Console.WriteLine(thais.ToString());
            Console.Read();

            var pupilGrade1Plus6 = pupils.Where(pupil => pupil.Age > 6 && pupil.Grade == 1);

            foreach (Pupil pupil in pupilGrade1Plus6)
            {
                Console.WriteLine(pupil);
            }

            Console.Read();
            Console.Clear();

            var listFusion = persons.Union(pupils);

            foreach (Person person in listFusion)
            {
                Console.WriteLine(person);
            }

            Console.Read();
            Console.Clear();

            IEnumerable <Pupil> listPupilsNoDuplicated = pupils.Distinct <Pupil>(new PersonComparer());

            foreach (Pupil pupil in listPupilsNoDuplicated)
            {
                Console.WriteLine(pupil);
            }

            Console.Read();
        }
Example #5
0
        static void Main(string[] args)
        {
            Pupil eleve1 = new Pupil("Toto", 10);
            Pupil eleve2 = new Pupil("Paul", 15);
            Pupil eleve3 = new Pupil("Messi", 18);
            Activity activity1 = new Activity("vélo",false);
            Activity activity2 = new Activity("piscine", true);
            Activity activity3 = new Activity("marche", true);
            Activity activity4 = new Activity("Ping pong", false);
            Activity activity5 = new Activity("Tir", false);
            Activity activity6 = new Activity("Foot", true);
            Activity activity7 = new Activity("coloriage", true);
            Activity activity8 = new Activity("cuisine", false);
            Activity activity9 = new Activity("bricolage", false);
            Activity activity10 = new Activity("musique", true);
            Activity activity11 = new Activity("basket", true);

          
             eleve1.AddActivity(activity1.Title);
             eleve1.AddActivity(activity2.Title);
             eleve1.AddEvaluation(evaluation: 'T', titre: "vélo");

             eleve2.AddActivity(activity3.Title);
             eleve2.AddActivity(activity2.Title);

             eleve2.AddEvaluation("piscine", 'R');
             eleve2.AddEvaluation("marche", 'T');
             eleve2.AddEvaluation("vélo");

    //         System.Console.Write(eleve1);
             System.Console.Write("\n\n");
             System.Console.Write(eleve2);
             System.Console.ReadKey();
             System.Console.Write("\n\n");
             System.Console.Write(eleve2.GetEvatuation("vélo"));
             System.Console.ReadKey();
             System.Console.Write("\n\n");
             /* 
 //Variable anonyme
             System.Console.Write("Variable anonyme \n");
             List<Pupil> listePupil = new List<Pupil>()
             {
                 new Pupil("Laura",13,3),
                 new Pupil("Schumi",11,2),
                 new Pupil("Tomi",9),
                 new Pupil("Sacha",5),
                 new Pupil("Samy",4),
                 new Pupil("Fred",6,1),
                 new Pupil("Valérie",5),
                 new Pupil("Alonso",3),
             };

             var pupilGrade1Plus6 = from eleve in listePupil
                                    where eleve.Grade == 1 && eleve.Age > 6
                                    select eleve;

             if(pupilGrade1Plus6 != null)
                 foreach (var eleves in pupilGrade1Plus6)
                 {
                     System.Console.Write(eleves.ToString() + "\n");
                 }

             System.Console.ReadKey();
             System.Console.Write("\n\n");

// Classe statique
             System.Console.Write("Classe statique \n");
             eleve3.addActivity(activity1);
             eleve3.addActivity(activity2);
             eleve3.addActivity(activity3);
             eleve3.addActivity(activity4);
             eleve3.addActivity(activity5);
             eleve3.addActivity(activity6);
             eleve3.addActivity(activity7);
             //eleve3.addActivity(activity8);
             eleve3.addActivity(activity9);
             eleve3.addActivity(activity10);
             eleve3.addActivity(activity11);
             System.Console.Write(eleve3);
             System.Console.ReadKey();

//Lambda*/
            /*System.Console.Write("Lambda \n");
            List<Pupil> listePupil = new List<Pupil>()
            {
                new Pupil("Laura",13,3),
                new Pupil("Schumi",11,2),
                new Pupil("Tomi",9),
                new Pupil("Sacha",5),
                new Pupil("Samy",4),
                new Pupil("Fred",6,1),
                new Pupil("Valérie",5),
                new Pupil("Alonso",3),
            };

            var pupilGrade1Plus6 = listePupil.Where(pupil => (pupil.Age > 6 && pupil.Grade == 1));
            if (pupilGrade1Plus6 != null)
                foreach (var eleves in pupilGrade1Plus6)
                {
                    System.Console.Write(eleves.ToString() + "\n");
                }
            */

//Cavariance
            /*
            System.Console.Write("Cavariance \n");
            List<Pupil> listPupils = new List<Pupil>() { 
                new Pupil("Léo",18,4),
                new Pupil("Bernie",12,2),
                new Pupil("Celine",15,3),
                new Pupil("Homer",5),
            };

            List<Person> listPerson = new List<Person>() { 
                new Pupil("Bart",18),
                new Pupil("Lisa",12),
                new Pupil("Marge",15),
                new Pupil("Magie",12),
            };

            var listFusion = listPerson.Union(listPupils);
            foreach (var pers in listFusion)
            {
                System.Console.Write(pers.ToString() + "\n");
            }

            List<Pupil> listPupilsDuplicated = new List<Pupil>() { 
                new Pupil("Jules",18),
                new Pupil("Nico",15),
                new Pupil("Jules",18),                
                new Pupil("Nico",15),
            };
            System.Console.ReadKey();
            System.Console.Write("Doublon \n");
            IEnumerable<Pupil> listPupilsNoDuplicated = listPupilsDuplicated.Distinct<Pupil>(new PersonComparer());

            foreach (var pers in listPupilsNoDuplicated)
            {
                System.Console.Write(pers.ToString() + "\n");
            }
            */
            System.Console.ReadKey();


           
        }