Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Student a = new Student("lala", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student b = new Student("www", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student g = new Student("aba", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student s = new Student("aaa", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            List<Student> studentList = new List<Student>();
            studentList.Add(a);
            studentList.Add(b);
            studentList.Add(s);
            studentList.Add(g);
            studentList.Add(new Student("aba", "aol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                            "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical));
            studentList.Add(new Student("aba", "aol", "rofl", "hladilnika", 686, 088811111, "*****@*****.**",
                            "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical));

            studentList.Sort();

            foreach (var item in studentList)
            {
                Console.WriteLine(item.ToString());
            }
        }
        static void Main(string[] args)
        {
            Student userStudOne = new Student("Georgi", "Vasilev", "Petrov", 1234567890, 1234567890, "*****@*****.**", 3,
                Student.Universities.technicalUniversity, Student.Faculties.mechanicalEngineering, Student.Specialties.mechatronics);
            Student userStudTwo = new Student("Petyr", "Georgiev", "Vasilev", 1324567890, 1234567098, "*****@*****.**", 2,
                Student.Universities.sofiqUniversity, Student.Faculties.phisics, Student.Specialties.nuclearPhysics);

            //Methods test
            string toStringTest = userStudOne.ToString();
            int getHashCodeTest = userStudOne.GetHashCode();
            bool equalsTest = userStudOne.Equals(userStudTwo);
            bool operatorsTestOne = userStudOne == userStudTwo;
            bool operatorsTestTwo = userStudOne != userStudTwo;
            Student cloneTest = (Student)userStudTwo.Clone(); //Clone() returns object, that's why I'm casting to Student.

            Console.WriteLine(toStringTest);
            Console.WriteLine("-------------\n-------------");
            Console.WriteLine(getHashCodeTest); //No idea...
            Console.WriteLine(equalsTest);
            Console.WriteLine(operatorsTestOne);
            Console.WriteLine(operatorsTestTwo);
            Console.WriteLine("-------------\n-------------");
            Console.WriteLine(cloneTest.ToString());
            Console.WriteLine(userStudOne.CompareTo(userStudTwo));
        }
Exemplo n.º 3
0
        static void Main()
        {
            Student student1 = new Student("Ivan", "Ivanov", "Ivankov", "111155555","Sofia", "0888888888", "*****@*****.**",
                "III", University.UASG, Faculty.Engineering, Specialty.CivilEngineer );
            Student student2 = new Student("Milen", "Milenov", "Milenkov", "222233333");
            Student student3 = new Student("Ivan", "Ivanov", "Ivankov", "111155555");

            //test task 1.
            Console.WriteLine("TEST TASK 1.");
            Console.WriteLine(student1.Equals(student2));
            Console.WriteLine(student1.Equals(student3));
            Console.WriteLine(student1 == student2);
            Console.WriteLine(student1 != student2);
            Console.WriteLine(student1.GetHashCode());
            Console.WriteLine(student1);

            //test task 2.
            Console.WriteLine("TEST TASK 2.");
            Student student4 = student2.Clone();
            student4.FirstName = "Gogo";
            Console.WriteLine(student4.FirstName);
            Console.WriteLine(student2.FirstName);

            //test task 3.
            Console.WriteLine();
            Console.WriteLine("TEST TASK 3.");
            Console.WriteLine(student1.CompareTo(student2));
            Console.WriteLine(student1.CompareTo(student3));
        }
        static void Main(string[] args)
        {
            Student a = new Student("lala", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student b = new Student("www", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student s = new Student("aaa", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            List<Student> initialList = new List<Student>();
            initialList.Add(a);
            initialList.Add(b);
            initialList.Add(s);

            foreach (var item in initialList)
            {
                Console.WriteLine(item.ToString());
            }

            List<Student> ClonedList = new List<Student>();

            foreach (var item in initialList)
            {
                ClonedList.Add((Student)item.Clone());
            }

            Console.WriteLine("\nPrinting the cloned list: ");
            foreach (var item in ClonedList)
            {
                Console.WriteLine(item.ToString());
            }

            ClonedList[0].GetFirstName = "change1";
            ClonedList[1].GetFirstName = "change2";
            ClonedList[2].GetFirstName = "change3";
            Console.WriteLine("\n\nPrinting the cloned list after change: ");
            foreach (var item in ClonedList)
            {
                Console.WriteLine(item.ToString());
            }

            Console.WriteLine("\nThe initial list: ");
            foreach (var item in initialList)
            {
                Console.WriteLine(item.ToString());
            }
        }
Exemplo n.º 5
0
        public static void Student()
        {
            Student myStudent = new Student();

            myStudent.FirstName = "Bonasera";
            myStudent.LastName = "Seniorita";
            myStudent.Faculty = Faculty.IT;
            myStudent.University = University.TelerikAcademy;
            myStudent.Specialty = Specialty.Chemistry;

            // testing cloning
            var clonedStudent = myStudent.Clone() as Student;
            Console.WriteLine("clonedStudent is Student: {0}", clonedStudent is Student);

            // Testing deep cloning
            myStudent.FirstName = "Mondial";
            Console.WriteLine("myStudent: {0}", myStudent.FirstName);
            Console.WriteLine("clonedStudent: {0}", clonedStudent.FirstName);

            clonedStudent.FirstName = "Mondial";
            Console.WriteLine("myStudent: {0}", myStudent.FirstName);
            Console.WriteLine("clonedStudent: {0}", clonedStudent.FirstName);

            // testing Equals
            Console.WriteLine("myStudent.Equals(clonedStudent): {0}", myStudent.Equals(clonedStudent));

            // testing .ToString();
            Console.WriteLine("clonedStudent Information: \n {0}", clonedStudent.ToString());
            // testing .GetHashCode();
            Console.WriteLine("GetHashCode() = {0}", clonedStudent.GetHashCode());

            // testing == and !=
            Console.WriteLine("myStudent==clonedStudent: {0}", myStudent == clonedStudent);
            Console.WriteLine("myStudent!=clonedStudent: {0}", myStudent != clonedStudent);

            // testing CompareTo
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));

            myStudent.FirstName = "AAAA";
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));
            myStudent.FirstName = "ZZZZ";
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));
            clonedStudent.FirstName = "ZZZZ";
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));
            clonedStudent.SSN = "123";
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));
            myStudent.SSN = "456";
            Console.WriteLine("myStudent.CompareTo(clonedStudent): {0}", myStudent.CompareTo(clonedStudent));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Student one = new Student("vfdv", "vfvfv", "vfv", "34ff43r4v0");
            Student two = new Student("fdvfdv", "vfdvdfv", "vfvfdvfdvdf", "34324ffdv3", "tam nqkude testvam, malko az", "90839489", "*****@*****.**",
                Course.Fourth, Faculty.Economics, Specialty.Audit, University.UNSS);

            Console.WriteLine(one.ToString());
            Console.WriteLine(two.ToString());
            Console.WriteLine(one.SSN == two.SSN);

            var clonedOne = two.Clone() as Student;
            Console.WriteLine(clonedOne.ToString());
            Console.WriteLine(one.GetHashCode());
            Console.WriteLine(two.GetHashCode());
            clonedOne.FirstName = "fdvfv";
            Console.WriteLine(clonedOne.GetHashCode());
        }
Exemplo n.º 7
0
        static void Main()
        {
            Student firstStudent = new Student("Nikolai", "Stefanov", "Gerasimov", "9301139844", "Gr.Pirdop str.Malinska",
                                                "088811155874", "*****@*****.**", 3, Specialty.KST, Faculty.FKSU,
                                                University.TuSofiq);
            Student secondStudent = new Student("Stefan", "Stefanov", "Nikolov", "9402237651", "Gr.Sofia str.PenchoSlaveikov",
                                                "0888175222","*****@*****.**", 3, Specialty.Mehatronika, Faculty.MF,
                                                 University.TuVarna);
            Student thirdStudent = secondStudent.Clone();

            bool chekSt = secondStudent == firstStudent;

            Console.WriteLine("Student 1: \n" + firstStudent.ToString());
            Console.WriteLine("Student 2: \n" + secondStudent.ToString());
            Console.WriteLine("Student 3: \n" + thirdStudent.ToString());
            Console.WriteLine("Do student1 match student2 : " + firstStudent.Equals(secondStudent));
            Console.WriteLine("Do student2 match student3 : " + secondStudent.Equals(thirdStudent));

            //Console.WriteLine(firstStudent == secondStudent);
            //Console.WriteLine(thirdStudent != firstStudent);
        }
Exemplo n.º 8
0
        static void Main()
        {
            Student s1 = new Student("Ivan", "Ivanov", "Ivanov", 0011223344, "Sofia", "*****@*****.**", 4, Specialties.ComputerScience, Universities.SofiaUniversity, Faculties.FMI);

            Student s2 = new Student("Gogo", "Georgiev", "Ivanov", 1122334455, "Sofia", "*****@*****.**", 2, Specialties.Law, Universities.TechnicalUniversity, Faculties.FacultyOfLaw);

            Console.WriteLine("s1 HashCode: " + s1.GetHashCode());
            Console.WriteLine("s1 HashCode: " + s2.GetHashCode());
            Console.WriteLine("s1 equals s2: " + s1.Equals(s2));
            Console.WriteLine("s1 == s2: " + (s1 == s2));
            Console.WriteLine("s1 != s2: " + (s1 != s2));
            Console.WriteLine();
            Console.WriteLine(s2.ToString());
            Console.WriteLine();

            Student s3 = (Student)s2.Clone();

            Console.WriteLine("s2 == s3: " + (s2 == s3));
            Console.WriteLine("s2 != s3: " + (s2 != s3));
            Console.WriteLine("s2.CompareTo(s3): " + s2.CompareTo(s3));
            Console.WriteLine("s1.CompareTo(s2): " + s1.CompareTo(s2));
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Student a = new Student("lala", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Student b = new Student("lala", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);

            Console.WriteLine(a.ToString());
            Console.WriteLine(b.ToString());

            if (a == b)
            {
                Console.WriteLine("a == b");
            }

            if (a.Equals(b))
            {
                Console.WriteLine("Equals ");
            }

            if (a != b)
            {
                Console.WriteLine("a and b are not equal");
            }

            Console.WriteLine(a.GetHashCode());
            Console.WriteLine(b.GetHashCode());

            Student s = new Student("lala1", "lol", "rofl", "hladilnika", 666, 088811111, "*****@*****.**",
                "Hardware manufacturing", Specialty.KST, University.FreeUniversity, Faculty.Technical);
            Console.WriteLine(s.GetHashCode());

            if (a != s)
            {
                Console.WriteLine("a and c are not equal");
            }
        }
Exemplo n.º 10
0
 public int CompareTo(Student s)
 {
     if (firstName.CompareTo(s.firstName) != 0) //if they are not equal
     {
         return firstName.CompareTo(s.firstName);
     }
     else if (middleName.CompareTo(s.middleName) != 0)
     {
         return middleName.CompareTo(s.middleName);
     }
     else if (lastName.CompareTo(s.lastName) != 0)
     {
         return lastName.CompareTo(s.lastName);
     }
     else
     {
         return ssn.CompareTo(s.ssn);
     }
 }