static void Main()
        {
            var studentMaria = new Student("Maria", "Petrova","985112", 3, Specialty.BiologyTeacher, University.SofiaUneversity, Faculty.Biology);
            var studentPesho = new Student("Pesho", "Peshev", "159876", 4, Specialty.SoftwareEngineer, University.Technical, Faculty.Electronics);
            var otherPesho = studentPesho.Clone() as Student;

            Console.WriteLine("Compare Pesho and otherPesho:");
            Console.WriteLine("Equal: "+ studentPesho.Equals(otherPesho));
            Console.Write("==: ");
            Console.WriteLine( studentPesho == otherPesho);
            Console.Write("!=: ");
            Console.WriteLine(studentPesho != otherPesho);
            Console.WriteLine();
            Console.WriteLine("Compare Pesho and Maria:");
            Console.WriteLine("Equal: " + studentPesho.Equals(studentMaria));
            Console.Write("==: ");
            Console.WriteLine(studentPesho == studentMaria);
            Console.Write("!=: ");
            Console.WriteLine(studentPesho != studentMaria);
            Console.WriteLine();

            otherPesho.SSN = "546549";

            Console.WriteLine("Original Pesho:\n" +studentPesho.ToString());
            Console.WriteLine("Cloned Pesho:\n"+otherPesho.ToString());
            Console.WriteLine("Compairing Pesho and otherPesho " +studentPesho.CompareTo(otherPesho));
            Console.WriteLine("Compare Pesho and otherPesho:");
            //Console.WriteLine("Equal: " + studentPesho.Equals(otherPesho));
            Console.Write("==: ");
            //Console.WriteLine(studentPesho == otherPesho);
            Console.Write("!=: ");
            //Console.WriteLine(studentPesho != otherPesho);
            Console.WriteLine();
        }
Exemplo n.º 2
0
        static void Main()
        {
            //whatever you want to test here
            Student stud1 = new Student("Pesho", "Peshev", 123);
            Student stud2 = new Student("Pesho", "Peshev", 123);

            Console.WriteLine(stud1.CompareTo(stud2));
        }
        public static void Main(string[] args)
        {
            Student firstStudent = new Student(
                "Pesho",
                "Peshov",
                "Peshov",
                12134314,
                "some address",
                "+359888 888 888",
                "*****@*****.**",
                UniversityEnum.TechnicalUniversity,
                FacultyEnum.FTK,
                SpecialtyEnum.TK,
                CourseEnum.First);

            Student testEqualStudent = new Student(
                "Pesho",
                "Peshov",
                "Peshov",
                12134314,
                "some address",
                "+359888 888 888",
                "*****@*****.**",
                UniversityEnum.TechnicalUniversity,
                FacultyEnum.FTK,
                SpecialtyEnum.TK,
                CourseEnum.First);

            Student secondStudent = new Student(
                "Gosho",
                "Goshov",
                "Goshov",
                12134315,
                "another address",
                "+359888 999 999",
                "*****@*****.**",
                UniversityEnum.TelericAcademy,
                FacultyEnum.Ninja,
                SpecialtyEnum.TelericAcademyNinja,
                CourseEnum.Second);

            Console.WriteLine("First student equals second student: {0}", firstStudent.Equals(secondStudent));

            Console.WriteLine("First student == test equal student student: {0}", firstStudent == testEqualStudent);

            Console.WriteLine("\nStudent.ToString():\n{0}", firstStudent.ToString());

            Student clonedStudent = (Student)secondStudent.Clone();

            Console.WriteLine("Deep cloned student:\n{0}", clonedStudent.ToString());

            Console.WriteLine("First student compared to second student: {0}", firstStudent.CompareTo(secondStudent));

            Console.WriteLine("Second student compared to cloned student: {0}", secondStudent.CompareTo(clonedStudent));

            Console.WriteLine("Second student compared to first student: {0}", secondStudent.CompareTo(firstStudent));
        }
        public static void TestStudentClass()
        {
            var ivanStudent = new Student(
                "Ivan",
                "Ivanov",
                "Ivanov",
                "111215439",
                "Tsar Ivan Asen II - Sofia",
                "0899456782",
                "vankata_seksipich",
                3,
                Specialty.AppliedMathematics,
                University.TechnicalUniversity,
                Faculty.Mathematics);

            var ivailoStudent = new Student(
                "Ivailo",
                "Petrov",
                "Ivanov",
                "111215114",
                "Shiroka - Sofia",
                "093651104",
                "ivo.andonov33",
                3,
                Specialty.DentalMedicine,
                University.Harvard,
                Faculty.Medicine);

            // printing ivan information to check the ToString() method implementation
            Console.WriteLine(ivanStudent);
            Console.WriteLine("==================");

            // getting ivailoStudent hashCode to chek the GetHashCode() method implementation
            Console.WriteLine("ivailoStudent hashcode: {0}", ivailoStudent.GetHashCode());

            // checkinng the == and != operators by comapring the two students
            Console.WriteLine("Are students equal: {0}", ivailoStudent == ivanStudent);

            // Console.WriteLine("Are students equal: {0}", ivailoStudent == (Student)ivailoStudent.Clone());
            Console.WriteLine("Are students not equal: {0}", ivailoStudent != ivanStudent);

            // testing the CompareTo method implementation
            Console.WriteLine("CompareTo() result: {0}", ivailoStudent.CompareTo(ivanStudent));
            Console.WriteLine("============");

            // testing the clone method
            var cloneIvan = (Student)ivanStudent.Clone();

            Console.WriteLine("Cloned student info:");
            Console.WriteLine(cloneIvan);

            Console.WriteLine("ivanStudent and clone object of ivanStudent have the same refference: {0}", ReferenceEquals(ivanStudent, cloneIvan));
            Console.WriteLine(ReferenceEquals(ivanStudent, ivanStudent));
        }
Exemplo n.º 5
0
        static void Main()
        {
            Name    petio           = new Name("Peter", "Petrov", "Petranov");
            Address petioHome       = new Address("Kaspichan", "Vasil Levski", 5);
            Student petioTheStudent = new Student(petio, "123-45-7890", petioHome, "088-777-666", "*****@*****.**", 3, Specialties.CSharpProgrammer, Universities.TelerikAcademy, Faculties.Second);

            Console.WriteLine(petioTheStudent);
            Console.WriteLine(petioTheStudent.GetHashCode());

            Student copyOfPetio = (Student)petioTheStudent.Clone();

            Console.WriteLine(object.ReferenceEquals(petioTheStudent.Name.FirstName, copyOfPetio.Name.FirstName));
            Console.WriteLine(object.ReferenceEquals(petioTheStudent.SSN, copyOfPetio.SSN));

            Console.WriteLine(petioTheStudent.CompareTo(copyOfPetio));
        }