public static void Main()
        {
            // Examples
            Student studentIvan = new Student("Ivan", "Manolov", "Kodev", 1175443445, "ul.Asenevci N3, Shumen", "+359895888333", "*****@*****.**", 3, University.Oxford, Specialty.French, Faculty.Alpha);
            Student studentDimcho = new Student("Dimcho", "Buhov", "Kostov", 1145345682, "ul.Padashti kotki, Sopot", "+359895123123", "*****@*****.**", 1, University.Harvard, Specialty.Biology, Faculty.Faculty3);

            // Crate array of Students
            Student[] students = new Student[] { studentIvan,studentDimcho};

            // Print
            Console.WriteLine("All students:\n");
            foreach (var student in students)
            {
                Console.WriteLine(student);
                Console.WriteLine();
            }

            // Check the overrited methods
            Console.WriteLine("\nIs Ivan == Dimcho?\n");
            Console.WriteLine(studentIvan == studentDimcho);

            Console.WriteLine("\nIs Ivan != Dimcho?\n");
            Console.WriteLine(studentIvan != studentDimcho);

            Console.WriteLine("\nIs Ivan equal to Dimcho?\n");
            Console.WriteLine(studentIvan.Equals(studentDimcho));

            Console.WriteLine("\nIvan compared with Dimcho:\n");
            Console.WriteLine(studentIvan.CompareTo(studentDimcho));

            Console.WriteLine("\nIvan HashCode:\n");
            Console.WriteLine(studentIvan.GetHashCode());
            Console.WriteLine("\nDimcho HashCode:\n");
            Console.WriteLine(studentDimcho.GetHashCode());

            Console.WriteLine("\nDimcho is copied...\n");
            var studentDimcho2 = studentDimcho.Clone();                         // Deep clone/sopy , element by element

            Console.WriteLine("\nIs DImcho compared with copied Dimcho?\n");
            Console.WriteLine(studentDimcho.CompareTo(studentDimcho2));

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho?\n");
            Console.WriteLine(studentDimcho.Equals(studentDimcho2));           // Should be true

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho by reference?\n");
            Console.WriteLine(ReferenceEquals(studentDimcho2,studentDimcho)); // Should be false
            Console.WriteLine("\nNice!");



            



        }
 static void Main()
 {
     var st1 = new Student() { FirstName = "Mimi", LastName = "Ivanova", SSN = 589762, Specialty = Specialty.Mathematics };
     var st2 = new Student() { FirstName = "Mimito", LastName = "Ivanova" };
     var st3 = new Student() { FirstName = "Mimi", LastName = "Ivanova", SSN = 125639, Specialty = Specialty.Informatics };
     Console.WriteLine(st1.Equals(st2));
     Console.WriteLine(st1.Equals(st3));
     Console.WriteLine(st1 == st2);
     Console.WriteLine(st1.ToString());
     Console.WriteLine(st3.GetHashCode());
     Console.WriteLine(st1.Clone().ToString());
     Console.WriteLine(st1.CompareTo(st3));
 }
        static void Main()
        {
            Student firstStudent = new Student("Pesho", "Peshev", "Peshev", 123456789, "Sofia", "0888736728",
                                               "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student secondStudent = new Student("Ivan", "Ivanov", "Ivanov", 124564789, "Varna", "0888678728",
                                                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student thirdStudent = (Student)firstStudent.Clone();

            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), secondStudent.ToString(), firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));

            thirdStudent.Ssn = 123456790;
            Console.WriteLine("Compare {0} and {1} with different SSN: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));
        }
        static void Main()
        {
            Student firstStudent = new Student("Pesho", "Peshev", "Peshev", 123456789, "Sofia", "0888736728",
                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student secondStudent = new Student("Ivan", "Ivanov", "Ivanov", 124564789, "Varna", "0888678728",
                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student thirdStudent = (Student)firstStudent.Clone();

            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), secondStudent.ToString(), firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));

            thirdStudent.Ssn = 123456790;
            Console.WriteLine("Compare {0} and {1} with different SSN: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Student st1 = new Student("Ivan", "Ivanov", "Ivanov", "8707070707", null, null, null, null, Specialty.Other, Faculty.Other, University.Other);
            Student st2 = new Student("Petar", "Petrov", "Petrov", "8808080808", null, null, null, null, Specialty.Other, Faculty.Other, University.Other);

            object st3 = st1.Clone();                               //Deep copy

            Console.WriteLine(st1.CompareTo(st2));

            Console.WriteLine(st1.CompareTo(st3 as Student));
            Console.WriteLine(st1 == st3);

            Console.WriteLine(st1);
            Console.WriteLine(st2);
        }
Exemple #6
0
        public static void Main()
        {
            // Examples
            Student studentIvan   = new Student("Ivan", "Manolov", "Kodev", 1175443445, "ul.Asenevci N3, Shumen", "+359895888333", "*****@*****.**", 3, University.Oxford, Specialty.French, Faculty.Alpha);
            Student studentDimcho = new Student("Dimcho", "Buhov", "Kostov", 1145345682, "ul.Padashti kotki, Sopot", "+359895123123", "*****@*****.**", 1, University.Harvard, Specialty.Biology, Faculty.Faculty3);

            // Crate array of Students
            Student[] students = new Student[] { studentIvan, studentDimcho };

            // Print
            Console.WriteLine("All students:\n");
            foreach (var student in students)
            {
                Console.WriteLine(student);
                Console.WriteLine();
            }

            // Check the overrited methods
            Console.WriteLine("\nIs Ivan == Dimcho?\n");
            Console.WriteLine(studentIvan == studentDimcho);

            Console.WriteLine("\nIs Ivan != Dimcho?\n");
            Console.WriteLine(studentIvan != studentDimcho);

            Console.WriteLine("\nIs Ivan equal to Dimcho?\n");
            Console.WriteLine(studentIvan.Equals(studentDimcho));

            Console.WriteLine("\nIvan compared with Dimcho:\n");
            Console.WriteLine(studentIvan.CompareTo(studentDimcho));

            Console.WriteLine("\nIvan HashCode:\n");
            Console.WriteLine(studentIvan.GetHashCode());
            Console.WriteLine("\nDimcho HashCode:\n");
            Console.WriteLine(studentDimcho.GetHashCode());

            Console.WriteLine("\nDimcho is copied...\n");
            var studentDimcho2 = studentDimcho.Clone();                         // Deep clone/sopy , element by element

            Console.WriteLine("\nIs DImcho compared with copied Dimcho?\n");
            Console.WriteLine(studentDimcho.CompareTo(studentDimcho2));

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho?\n");
            Console.WriteLine(studentDimcho.Equals(studentDimcho2));           // Should be true

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho by reference?\n");
            Console.WriteLine(ReferenceEquals(studentDimcho2, studentDimcho)); // Should be false
            Console.WriteLine("\nNice!");
        }
        public static void Main()
        {
            Student firstStudent = new Student();
            Student secondStudent = new Student();
            secondStudent.Course = 5;
            secondStudent.FistName = "Pesho";
            secondStudent.SSN = 6;
            Console.WriteLine(firstStudent == secondStudent);
            Console.WriteLine(firstStudent.Equals(secondStudent));

            Student someStudent = (Student)secondStudent.Clone();
            someStudent.FistName = "Gosho";
            someStudent.SSN = 7;
            Console.WriteLine(secondStudent.FistName);
            Console.WriteLine(someStudent.FistName);
            Console.WriteLine(secondStudent.CompareTo(someStudent));
        }
        static void Main(string[] args)
        {
            Student peshoStud = new Student("Pesho", "Petrov", "Peshev", 9006036584, 1, "*****@*****.**", University.SofiaUniversity,
                                            Faculty.Physics, Specialty.Physics);
            Student ivanStud = new Student("Pesho", "Petrov", "Peshev", 9006036584, 1, "*****@*****.**", University.SofiaUniversity,
                                           Faculty.Physics, Specialty.Physics);

            Console.WriteLine(peshoStud.CompareTo(ivanStud));

            Console.WriteLine(peshoStud.Equals(ivanStud));
            Console.WriteLine(peshoStud.GetHashCode());
            Console.WriteLine(ivanStud.GetHashCode());
            Console.WriteLine(peshoStud.ToString());
            Console.WriteLine(peshoStud == ivanStud);
            Console.WriteLine(peshoStud != ivanStud);

            var cloned = ivanStud.Clone() as Student;

            Console.WriteLine(ivanStud.SSN);
            Console.WriteLine(cloned.SSN);
        }
        static void Main()
        {
            Student kristian = new Student
                               (
                "Kristian",
                "Georgiev",
                "Ivanov",
                "5456654",
                "Sofia",
                "0888877869",
                "*****@*****.**",
                "3 course",
                Specialty.SoftwareEngineering,
                University.SofiaUniversity,
                Faculty.MathematicsInformatics
                               );

            Student vili = new Student
                           (
                "Vili",
                "Georgieva",
                "Ivanova",
                "54566543",
                "Sofia",
                "08888887869",
                "*****@*****.**",
                "3 course",
                Specialty.SoftwareEngineering,
                University.SofiaUniversity,
                Faculty.MathematicsInformatics
                           );

            Student kris = (Student)kristian.Clone(); // Clone

            // Console.WriteLine(kristian.Equals(vili));
            // Console.WriteLine(kristian == vili);

            Console.WriteLine(kris);
        }
        static void Main()
        {
            Student kristian = new Student
                (
                    "Kristian",
                    "Georgiev",
                    "Ivanov",
                    "5456654",
                    "Sofia",
                    "0888877869",
                    "*****@*****.**",
                    "3 course",
                    Specialty.SoftwareEngineering,
                    University.SofiaUniversity,
                    Faculty.MathematicsInformatics
                );

            Student vili = new Student
                (
                    "Vili",
                    "Georgieva",
                    "Ivanova",
                    "54566543",
                    "Sofia",
                    "08888887869",
                    "*****@*****.**",
                    "3 course",
                    Specialty.SoftwareEngineering,
                    University.SofiaUniversity,
                    Faculty.MathematicsInformatics
                );

            Student kris = (Student)kristian.Clone(); // Clone
            // Console.WriteLine(kristian.Equals(vili));
            // Console.WriteLine(kristian == vili);

            Console.WriteLine(kris);
        }