Exemplo n.º 1
0
        static void Main()
        {
            List <Student> students = new List <Student>
            {
                new Student()
                {
                    Name = "Sally", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Bob", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Sally", GradeLevel = 2
                }
            };

            SchoolRoll schoolRoll = new SchoolRoll();

            schoolRoll.AddStudents(students);

            schoolRoll.AddStudents(students);
            //even having this command in twice, HashSet has ignored them. That is our desired outcome.

            foreach (Student student in schoolRoll.Students)
            {
                Console.WriteLine($"{student.Name} is in grade {student.GradeLevel}");
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            List <Student> students = new List <Student>
            {
                new Student()
                {
                    Name = "Sally", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Bob", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Sally", GradeLevel = 2
                }
            };

            SchoolRoll schoolRoll = new SchoolRoll();

            schoolRoll.AddStudents(students);

            schoolRoll.Students.RemoveAt(0);

            schoolRoll.Students.Sort();

            schoolRoll.Students.AddRange(students);


            foreach (Student student in schoolRoll.Students)
            {
                Console.WriteLine($"{student.Name} is in grade {student.GradeLevel}");
            }
        }
Exemplo n.º 3
0
        static void Main()
        {
            // HASHSET EXAMPLE
            List <Student> students = new List <Student>
            {
                new Student()
                {
                    Name = "Sally", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Bob", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Sally", GradeLevel = 2
                }
            };

            SchoolRoll schoolRoll = new SchoolRoll();

            schoolRoll.AddStudents(students);

            schoolRoll.AddStudents(students);

            foreach (Student student in schoolRoll.Students)
            {
                Console.WriteLine($"{student.Name} is in grade {student.GradeLevel}");
            }

            // DICTIONARY EXAMPLE
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(input))
                {
                    break;
                }

                string output = MorseCodeTranslator.ToMorse(input);

                Console.WriteLine(output);
            }
        }
Exemplo n.º 4
0
        static void Main()

        {
            List <Student> students = new List <Student>
            {
                new Student()
                {
                    Name = "Sally", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Bob", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Sally", GradeLevel = 2
                }
            };

            SchoolRoll schoolRoll = new SchoolRoll();

            schoolRoll.AddStudents(students);

            schoolRoll.Students.RemoveAt(0);
            schoolRoll.Students.Sort();
            schoolRoll.Students.AddRange(students);
            //students.Sort();

            //Student newStudent = new Student() { Name = "Joe", GradeLevel = 2 };

            //int index = students.BinarySearch(newStudent);

            //if (index < 0)
            //{
            //    students.Insert(~index, newStudent);
            //}

            foreach (Student student in schoolRoll.Students)
            {
                Console.WriteLine($"{ student.Name} is in grade {student.GradeLevel}");
            }
        }