Ejemplo n.º 1
0
        internal static void Main()
        {
            var firstStudent = new Student("Ivan", "Peshov", "Goshov", 12345, "Nqkuv Adres 1", 85467892,
                                           "*****@*****.**", "first course", Specialty.Informatics, University.SofiaUniversity, Faculty.Business);

            var secondStudent = new Student("Gosho", "Ivanov", "Peshov", 123456, "Nqkuv Adres 2", 743874384,
                                            "*****@*****.**", "second course", Specialty.InternationalBusiness, University.UNWE, Faculty.Chemistry);

            var thirdStudent = new Student("Pesho", "Goshov", "Ivanov", 1234567, "Nqkuv Adres 3", 75487545490,
                                           "*****@*****.**", "third course", Specialty.Informatics, University.SofiaUniversity, Faculty.Business);


            Console.WriteLine(firstStudent == secondStudent); //False
            Console.WriteLine(firstStudent != secondStudent); //True

            Console.WriteLine(firstStudent == thirdStudent);  //True
            Console.WriteLine(firstStudent != thirdStudent);  //False

            Console.WriteLine(firstStudent.GetHashCode());
            Console.WriteLine(secondStudent.GetHashCode());
            Console.WriteLine(thirdStudent.GetHashCode());

            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine(thirdStudent.ToString());

            var clonedStudent = firstStudent.Clone();

            Console.WriteLine("First student: " + firstStudent);
            Console.WriteLine("Cloned student: " + clonedStudent);

            Console.WriteLine(firstStudent.CompareTo(secondStudent));
        }
Ejemplo n.º 2
0
        private static void TestStudentClass()
        {
            var sb = new StringBuilder();

            var peshoStudent        = new Student("Pesho", "Peshov", 4, 222, Specialty.QA, University.TilirikUniversity, Faculty.SoftwareFaculty);
            var goshoStudent        = new Student("Gosho", "Goshov", 2, 123, Specialty.MobileDevelopment, University.TilirikUniversity, Faculty.SoftwareFaculty);
            var oneMorePeshoStudent = new Student("Pesho", "Goshov", 2, 456, Specialty.MobileDevelopment, University.TilirikUniversity, Faculty.SoftwareFaculty);
            var anotherPeshoStudent = peshoStudent.Clone();

            sb.AppendLine(peshoStudent.ToString())
            .AppendLine(goshoStudent.ToString())
            .AppendLine("Pesho equals Gosho?")
            .AppendFormat("Equals: {0}", peshoStudent.Equals(goshoStudent))
            .AppendLine()
            .AppendFormat("==: {0}", peshoStudent == goshoStudent)
            .AppendLine()
            .AppendFormat("!=: {0}", peshoStudent != goshoStudent)
            .AppendLine()
            .AppendLine("\nPesho cloned: ")
            .AppendLine(anotherPeshoStudent.ToString())
            .AppendLine("Compare Pesho & Gosho: " + peshoStudent.CompareTo(goshoStudent).ToString())
            .AppendLine("Compare Pesho & one more Pesho student: " + peshoStudent.CompareTo(oneMorePeshoStudent).ToString())
            .AppendLine("Compare Pesho & Pesho copy: " + peshoStudent.CompareTo(anotherPeshoStudent).ToString());

            Console.WriteLine(sb);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Student st = new Student("Ivan", "Ivanov", "Ivanov", "123456789",
                                     "Mladost 4, Sofia, Bulgaria", "0888888888", "*****@*****.**", 2,
                                     Specialty.Botany, Faculty.Biology, University.Oxford);

            Console.WriteLine(st.Email);
            Console.WriteLine(st.ToString());
            Console.WriteLine();

            Student st2 = st;
            Student st3 = new Student("Petar", "Petrov", "Petrov", "123321312",
                                      "Lyulin 18, Sofia, Bulgaria", "0999999999", "*****@*****.**", 2,
                                      Specialty.Botany, Faculty.Biology, University.Oxford);

            Console.WriteLine("Equals: {0}", st3.Equals(st));
            Console.WriteLine("== operator: {0}", st == st2);

            Console.WriteLine("HashCode: {0}", st.GetHashCode());

            Console.WriteLine();
            Console.WriteLine("Clone:");
            var st8 = st3.Clone();

            Console.WriteLine(st8.ToString());
            Console.WriteLine("Clone equals: {0}", st3.Equals(st8));
            Console.WriteLine("Clone == operator: {0}", st3 == st8);
            Console.WriteLine();
            Console.WriteLine(st.CompareTo(st3));
            Console.WriteLine();
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            Student firstStudent = new Student("Ivan", "Vasilev", "Georgiev", "234-23-4567", "Address", "0888345678", "*****@*****.**",
                                               1, Specialty.Biology, University.PlovdivUniversity, Faculty.BiologyFaculty);

            Console.WriteLine("First student:\n\n" + firstStudent);
            Console.WriteLine("First student hash code: {0}\n", firstStudent.GetHashCode());

            Student secondStudent = firstStudent;

            Console.WriteLine("Second student:\n\n" + secondStudent);

            Console.WriteLine("DoesReferenceEquals(firstStudent, secondStudent)? : {0}\n", ReferenceEquals(firstStudent, secondStudent));

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

            Console.WriteLine("Third student (cloned second student):\n\n" + thirdStudent);

            Console.WriteLine("DoesReferenceEquals(thirdStudent, secondStudent)? : {0}\n", ReferenceEquals(thirdStudent, secondStudent));

            secondStudent = new Student("Peter", "Pavlov", "Petrov", "888-23-4567", "Address", "0888345888", "*****@*****.**",
                                        2, Specialty.Chemistry, University.SofiaUniversity, Faculty.ChemistryFaculty);

            Console.WriteLine("Second student (changed):\n\n" + secondStudent);
            Console.WriteLine("Third student:\n\n" + thirdStudent);

            Console.WriteLine("firstStudent != secondStudent : {0}", firstStudent != secondStudent);
            Console.WriteLine("firstStudent.Equals(secondStudent)) : {0}", firstStudent.Equals(secondStudent));
            Console.WriteLine("firstStudent.CompareTo(secondStudent) : {0}\n", firstStudent.CompareTo(secondStudent));
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            var mathStudent = new Student("Ivan", "Toshev", "Petkov", 456813496, "Sofia, Mladost", "0865123654", "*****@*****.**", 4, Specialty.AppliedMathematics, Faculty.MathematicsFaculty, University.SU);
            var lawStudent  = new Student("Lila", "Lalova", "Lolova", 561323478, "Sofia, Obelia", "0888563211", "*****@*****.**", 3, Specialty.CivilLaw, Faculty.LawFaculty, University.SU);
            var itStudent   = new Student("Peter", "Toshev", "Ivanov", 996541207, "Sofia, Liulin", "0875636365", "*****@*****.**", 4, Specialty.SoftwareEngineering, Faculty.ComputerScienceAndTechnologyFaculty, University.SU);
            var chemStudent = new Student("Eva", "Hristova", "Roydeva", 558465892, "Sofia, Ovcha Kupel", "0889447100", "*****@*****.**", 5, Specialty.ChemicalEngineering, Faculty.EngineeringFaculty, University.UCTM);
            var busStudent  = new Student("Stoian", "Dimitrov", "Kostov", 775698223, "Sofia, Drujba", "0884654445", "*****@*****.**", 1, Specialty.BusinessAdministration, Faculty.BusinessAndManagementFaculty, University.UNWE);

            // ToString()
            Console.WriteLine(mathStudent);
            Console.WriteLine(chemStudent);

            // Equals()
            Console.WriteLine("\nTesting Equals()");
            Console.WriteLine(mathStudent.MiddleName == itStudent.MiddleName);
            Console.WriteLine(chemStudent.SocialSecurityNumber != busStudent.SocialSecurityNumber);

            // GetHashCode()
            Console.WriteLine("\nTesting GetHashCode()");
            Console.WriteLine(mathStudent.MiddleName.GetHashCode());
            Console.WriteLine(itStudent.MiddleName.GetHashCode());

            Console.WriteLine(lawStudent.SocialSecurityNumber.GetHashCode());
            Console.WriteLine(busStudent.SocialSecurityNumber.GetHashCode());

            // Clone()
            Console.WriteLine("\nTesting Clone()");
            Student newItStudentWithClone = (Student)itStudent.Clone();

            newItStudentWithClone.FirstName = "Stoian";
            Console.WriteLine(newItStudentWithClone.FirstName.CompareTo(itStudent.FirstName) == 0 ? "names are equal - clone NOT successful!" : "names are not equal - successful clone!");

            Student newItStudentWithoutClone = itStudent;

            newItStudentWithoutClone.FirstName = "Alex";
            Console.WriteLine(newItStudentWithoutClone.FirstName.CompareTo(itStudent.FirstName) == 0 ? "names are equal - clone NOT successful!" : "names are not equal - successful clone!");

            // CompareTo()
            Console.WriteLine("\nTesting CompareTo()");

            var students = new Student[]
            {
                new Student("Ivan", "Toshev", "Petkov", 456813496),
                new Student("Lila", "Lalova", "Lolova", 561323478),
                new Student("Ivan", "Toshev", "Ivanov", 996541207),
                new Student("Eva", "Hristova", "Roydeva", 558465892),
                new Student("Georgi", "Plamenov", "Titov", 663457986),
                new Student("Eva", "Hristova", "Roydeva", 654987123),
                new Student("Stoian", "Dimitrov", "Kostov", 775698223),
                new Student("Stoian", "Kamenov", "Popov", 665998420)
            };

            Array.Sort(students);
            foreach (var student in students)
            {
                Console.WriteLine(student.FirstName + " " + student.MiddleName + " " + student.LastName + " " + student.SocialSecurityNumber);
            }
        }
        static void Main()
        {
            Student firstStudent = new Student("Ivan", "Petrov", "Ivanov", "123456789", "Sofia",
                                               "0893457652", "*****@*****.**", 2);

            Student secondStudent = new Student();

            secondStudent = firstStudent.Clone() as Student;
        }
Ejemplo n.º 7
0
 static void Main()
 {
     Student pesho = new Student("Pesho", "Petrov", "Peshov", 59599595523, "Sofia, 5", "08885599595", "*****@*****.**", 3, Specialties.ElectricalEngineering, Universities.SofiaUni, Faculties.Math);
     Student ivan = new Student("Ivan", "Ivanchev", "Ivanov", 59587294523, "Plovdiv, 123", "0888737372", "*****@*****.**", 3, Specialties.English, Universities.PlovdivUni, Faculties.Linguistics);
     Student peshocopy = (Student)pesho.Clone();
     Console.WriteLine("ivan                       {0}", ivan);
     Console.WriteLine("pesho                      {0}", pesho);
     Console.WriteLine("peshocopy                  {0}", peshocopy);
     Console.WriteLine("pesho.CompareTo(ivan)      {0}", pesho.CompareTo(ivan));
     Console.WriteLine("pesho.CompareTo(peshocopy) {0}", pesho.CompareTo(peshocopy));
     Console.WriteLine("pesho == peshocopy         {0}", pesho == peshocopy);
     Console.WriteLine("pesho != peshocopy         {0}", pesho != peshocopy);
 }
Ejemplo n.º 8
0
        private static void TestStudent()
        {
            var stud = new Student("Pesho", "Ivanov", "Georgiev", "999-00-4444", "Pesho`s address is deep secret",
                                   "+1 155 1254845", "*****@*****.**", "Programming", Specialties.Engineering, Faculties.Programming,
                                   University.MIT);

            var evilTwin = (Student)stud.Clone();

            Console.WriteLine("GetHashCode() return: {0}", stud.GetHashCode() == evilTwin.GetHashCode());

            Console.WriteLine("Equals return: {0}", stud.Equals(evilTwin));

            Console.WriteLine("CompareTo return: {0}", stud.CompareTo(evilTwin));
        }
Ejemplo n.º 9
0
        private static void Main()
        {
            var pesho1 = new Student("Pesho", "Petrov", "Petrov", "999999999", "Kaspichan 2", "088889788", "*****@*****.**", 3, SpecialitiesEnum.Economics, UniversitiesEnum.Unss, FacultiesEnum.StatisticsAndInformatics);
            var pesho2 = new Student("Pesho", "Petrov", "Petrov", "999999999", "Kaspichan 2", "088889788", "*****@*****.**", 3, SpecialitiesEnum.Economics, UniversitiesEnum.Unss, FacultiesEnum.StatisticsAndInformatics);
            var gosho  = new Student("Gosho", "Georgiev", "Georgiev", "888888888", "Kaspichan 1", "089889788", "*****@*****.**", 3, SpecialitiesEnum.Biology, UniversitiesEnum.Su, FacultiesEnum.AppliedScience);

            Console.WriteLine("We have three students: ");
            Console.WriteLine(pesho1);
            Divide();
            Console.WriteLine(pesho2);
            Divide();
            Console.WriteLine(gosho);

            Divide();
            Console.ForegroundColor = ConsoleColor.Green;
            var areTheyEqual = pesho1.Equals(pesho2);

            Console.WriteLine("The Pesho and Pesho are equal: " + areTheyEqual + " => when we use CompareTo we get: " + pesho2.CompareTo(pesho1));

            areTheyEqual = pesho1.Equals(gosho);
            Console.WriteLine("The Pesho and Gosho are equal: " + areTheyEqual + " => when we use CompareTo we get: " + gosho.CompareTo(pesho1));

            areTheyEqual = pesho1 == pesho2;
            Console.WriteLine("The Pesho and Pesho are equal with equality operator: " + areTheyEqual);

            areTheyEqual = pesho1 == gosho;
            Console.WriteLine("The Pesho and Gosho are equal with equality operator: " + areTheyEqual);

            Console.WriteLine("Pesho hash code:" + pesho1.GetHashCode());
            Console.WriteLine("Second Pesho hash code: " + pesho2.GetHashCode());
            Console.WriteLine("Gosho hash code: " + gosho.GetHashCode());
            Divide();

            Console.WriteLine("Lets copy Gosho and change his info.");
            var ivan = (Student)gosho.Clone();

            ivan.FirstName  = "Ivan";
            ivan.LastName   = "Vladimirov";
            ivan.Ssn        = "777777777";
            ivan.Email      = "*****@*****.**";
            ivan.Address    = "Parvomai";
            ivan.Speciality = SpecialitiesEnum.BusinessAdministration;
            ivan.Faculty    = FacultiesEnum.StatisticsAndInformatics;
            Divide();
            Console.WriteLine(ivan);
            Divide();
            Console.WriteLine("Gosho is still the same.");
            Console.WriteLine(gosho);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
        static void Main()
        {
            var student1 = new Student("Damyan","Ralev","Chernev",40867,"8 Kanarche Street", "+359888000000","*****@*****.**", 4 ,University.UniversityOfForestry, Faculty.FacultyOfVeterinaryMedicine, Specialty.VeterinaryMedicine);
            Console.WriteLine(student1.ToString());

            Console.WriteLine();
            var student2 = new Student("Boris", "Sharkov", "Romanov", 40860, "4 Marko Balabanov Street", "+359888888888", "*****@*****.**", 2, University.SofiaUniversity, Faculty.FacultyOfBiology, Specialty.Biology);
            Console.WriteLine(student2.ToString());

            Console.WriteLine();
            var cloneStudent1 = student1.Clone();
            Console.WriteLine("First student's clone:\r\n{0}",cloneStudent1.ToString());

            Console.WriteLine(student1.CompareTo(student2));
        }
Ejemplo n.º 11
0
 private static void Main()
 {
     var test = new Student("Pesho", "Petrov", "Petrov", 192, "tri", "+359887005", "*****@*****.**", "Math", "Algorythms", "TU", "FMI");
     var test2 = new Student("Pesho", "Petrov", "Petrov", 193, "tri", "+359887005", "*****@*****.**", "Math", "Algorythms", "SU", "FMI");
     Console.WriteLine(test.GetHashCode());
     Console.WriteLine(test2.GetHashCode());
     Console.WriteLine(test.Equals(test2));
     Console.WriteLine(test);
     Console.WriteLine(test2);
     var clone = test.Clone();
     Console.WriteLine(clone);
     Console.WriteLine(test.Equals(clone));
     Console.WriteLine(test == clone);
     Console.WriteLine(test == clone as Student);
     Console.WriteLine(test.CompareTo(test2));
 }
Ejemplo n.º 12
0
 public static void Main()
 {
     var firstStudent = new Student("Ivan", "Ivanov", "Ivanov", 1234,"another adress", "+359888345678", "*****@*****.**", "Some Course", Specialty.Physics, Faculty.Mathemtics, University.MEI);
     var secondStudent = (Student)firstStudent.Clone();
     var thirdStudent = new Student("Gosho", "Georgiev", "Ivanov", 1233, "some address", "+359888123456", "*****@*****.**", "Some Course", Specialty.Physics, Faculty.Mathemtics, University.MEI);
     Console.WriteLine(firstStudent);
     Console.WriteLine(secondStudent);
     Console.WriteLine(thirdStudent);
     Console.WriteLine("First student == second student: {0}", firstStudent == secondStudent);
     Console.WriteLine("First student == third student: {0}", firstStudent == thirdStudent);
     Console.WriteLine("First student != third student: {0}", firstStudent != thirdStudent);
     Console.WriteLine("First studen GetHashCode(): {0}", firstStudent.GetHashCode());
     Console.WriteLine("Second studen GetHashCode(): {0}", secondStudent.GetHashCode());
     Console.WriteLine("Third studen GetHashCode(): {0}", thirdStudent.GetHashCode());
     Console.WriteLine(firstStudent.CompareTo(thirdStudent));
 }
Ejemplo n.º 13
0
        public static void Main()
        {
            var firstStudent  = new Student("Ivan", "Ivanov", "Ivanov", 1234, "another adress", "+359888345678", "*****@*****.**", "Some Course", Specialty.Physics, Faculty.Mathemtics, University.MEI);
            var secondStudent = (Student)firstStudent.Clone();
            var thirdStudent  = new Student("Gosho", "Georgiev", "Ivanov", 1233, "some address", "+359888123456", "*****@*****.**", "Some Course", Specialty.Physics, Faculty.Mathemtics, University.MEI);

            Console.WriteLine(firstStudent);
            Console.WriteLine(secondStudent);
            Console.WriteLine(thirdStudent);
            Console.WriteLine("First student == second student: {0}", firstStudent == secondStudent);
            Console.WriteLine("First student == third student: {0}", firstStudent == thirdStudent);
            Console.WriteLine("First student != third student: {0}", firstStudent != thirdStudent);
            Console.WriteLine("First studen GetHashCode(): {0}", firstStudent.GetHashCode());
            Console.WriteLine("Second studen GetHashCode(): {0}", secondStudent.GetHashCode());
            Console.WriteLine("Third studen GetHashCode(): {0}", thirdStudent.GetHashCode());
            Console.WriteLine(firstStudent.CompareTo(thirdStudent));
        }
Ejemplo n.º 14
0
        static void Main()
        {
            var student1 = new Student("Damyan", "Ralev", "Chernev", 40867, "8 Kanarche Street", "+359888000000", "*****@*****.**", 4, University.UniversityOfForestry, Faculty.FacultyOfVeterinaryMedicine, Specialty.VeterinaryMedicine);

            Console.WriteLine(student1.ToString());

            Console.WriteLine();
            var student2 = new Student("Boris", "Sharkov", "Romanov", 40860, "4 Marko Balabanov Street", "+359888888888", "*****@*****.**", 2, University.SofiaUniversity, Faculty.FacultyOfBiology, Specialty.Biology);

            Console.WriteLine(student2.ToString());

            Console.WriteLine();
            var cloneStudent1 = student1.Clone();

            Console.WriteLine("First student's clone:\r\n{0}", cloneStudent1.ToString());

            Console.WriteLine(student1.CompareTo(student2));
        }
Ejemplo n.º 15
0
        private static void Main()
        {
            var test  = new Student("Pesho", "Petrov", "Petrov", 192, "tri", "+359887005", "*****@*****.**", "Math", "Algorythms", "TU", "FMI");
            var test2 = new Student("Pesho", "Petrov", "Petrov", 193, "tri", "+359887005", "*****@*****.**", "Math", "Algorythms", "SU", "FMI");

            Console.WriteLine(test.GetHashCode());
            Console.WriteLine(test2.GetHashCode());
            Console.WriteLine(test.Equals(test2));
            Console.WriteLine(test);
            Console.WriteLine(test2);
            var clone = test.Clone();

            Console.WriteLine(clone);
            Console.WriteLine(test.Equals(clone));
            Console.WriteLine(test == clone);
            Console.WriteLine(test == clone as Student);
            Console.WriteLine(test.CompareTo(test2));
        }
Ejemplo n.º 16
0
        static void Main()
        {
            Student firstStudent = new Student("Ivan", "Ivanov", "Ivanov", "8912123434", "bul. Bulgaria 1", "0888888888", "*****@*****.**", 4, Specialty.CST, Faculty.FKSU, University.TUSofiya);

            Student secondStudent = new Student("Stefaniya", "Stefanova", "Stefanova", "9011115757", "bul. Al.Malinov 1", "0888555555", "*****@*****.**", 3, Specialty.EngineerDesign, Faculty.MF, University.TUSofiya);

            Student thirdStudent = new Student("Stefaniya", "Stefanova", "Stefanova", "9011115757", "bul. Al.Malinov 1", "0888555555", "*****@*****.**", 3, Specialty.EngineerDesign, Faculty.MF, University.TUSofiya);

            // Testing the ToString() method
            Console.WriteLine("Testing the ToString() method:");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine(firstStudent);
            Console.WriteLine(secondStudent);
            // Testing the GetHashCode() and Equals methods
            Console.WriteLine("Testing the GetHashCode() and Equals() methods:");
            Console.WriteLine(new string('-', 47));
            Console.WriteLine("Result of the Equals() method for the third and the second student: {0}", thirdStudent.Equals(secondStudent));
            Console.WriteLine("First student HashCode: " + firstStudent.GetHashCode());
            Console.WriteLine("Second student HashCode: " + secondStudent.GetHashCode());
            Console.WriteLine("Result of the Equals() method for the hashcodes of the first and the second student: " + firstStudent.GetHashCode().Equals(secondStudent.GetHashCode()));
            Console.WriteLine("Result of the Equals() method for the hashcodes of the third and the second student: " + thirdStudent.GetHashCode().Equals(secondStudent.GetHashCode()));
            Console.WriteLine();
            // Testing the == and != operators
            Console.WriteLine("Testing the == and != operators:");
            Console.WriteLine(new string('-', 32));
            Console.WriteLine("First student == Second student: {0}", firstStudent == secondStudent);
            Console.WriteLine("Second student == Third student: {0}", secondStudent == thirdStudent);
            Console.WriteLine("First student != Second student: {0}", firstStudent != secondStudent);
            Console.WriteLine("Second student != Third student: {0}", secondStudent != thirdStudent);
            Console.WriteLine();
            // Testing the Clone() method
            Console.WriteLine("Testing the Clone() method:");
            Console.WriteLine(new string('-', 27));
            Student copiedStudent = firstStudent.Clone() as Student;

            Console.WriteLine("First student clone == First student: {0}", copiedStudent == firstStudent);
            Console.WriteLine();
            // Testing the CompareTo() method
            Console.WriteLine("Testing the CompareTo() method:");
            Console.WriteLine(new string('-', 31));
            Console.WriteLine("First student compared to the second student: {0}", firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Second student compared to the first student: {0}", secondStudent.CompareTo(firstStudent));
            Console.WriteLine("Cloned student compared to the first student: {0}", copiedStudent.CompareTo(firstStudent));
        }
Ejemplo n.º 17
0
        static void Main()
        {
            Student student1 = new Student("Anton", "Dimitrov", "Ivanov", 1497845, "Ul. Briast 13", "099922233", "*****@*****.**", 2, Speciality.Statistic, University.TU, Faculty.Mathemathical);
            Student student2 = new Student("Anton", "Dimitrov", "Ivanov", 1497845, "Ul. Briast 13", "099922233", "*****@*****.**", 2, Speciality.Statistic, University.TU, Faculty.Mathemathical);

            Console.WriteLine("Student1.Equals(Student2) - {0}", student1.Equals(student2));
            student2.FirstName = "Ivan";
            Console.WriteLine("After changes in student 2 - Student1.Equals(Student2) - {0}", student1.Equals(student2));
            Console.WriteLine("student1 == student2 - {0}", student1 == student2);
            Console.WriteLine("student1 != student2 - {0}", student1 != student2);
            Console.WriteLine("Student1 hask code - {0}", student1.GetHashCode());
            Console.WriteLine();
            Console.WriteLine("02.IClonable");
            Console.WriteLine(new string('-', Console.WindowWidth));
            var clone = student1.Clone() as Student;

            Console.WriteLine("Clone of student1");
            Console.WriteLine(clone);
            Console.WriteLine();
            student1.FirstName  = "Darin";
            student1.Course     = 3;
            student1.Speciality = Speciality.FinancialManagment;
            Console.WriteLine("Student1 after some changes");
            Console.WriteLine(student1);
            Console.WriteLine();
            Console.WriteLine("Cloned student has not changed");
            Console.WriteLine(clone);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("03.IComparable");
            Console.WriteLine(new string('-', Console.WindowWidth));
            if (student1.CompareTo(student2) > 0)
            {
                Console.WriteLine("student1 < student2");
            }
            else if (student1.CompareTo(student2) < 0)
            {
                Console.WriteLine("student1 > student2");
            }
            else
            {
                Console.WriteLine("student1 = student2");
            }
        }
        static void Main()
        {
            Student firstStudent = new Student("Ivan", "Ivanov", "Ivanov", "8912123434", "bul. Bulgaria 1", "0888888888", "*****@*****.**", 4, Specialty.CST, Faculty.FKSU, University.TUSofiya);

            Student secondStudent = new Student("Stefaniya", "Stefanova", "Stefanova", "9011115757", "bul. Al.Malinov 1", "0888555555", "*****@*****.**", 3, Specialty.EngineerDesign, Faculty.MF, University.TUSofiya);

            Student thirdStudent = new Student("Stefaniya", "Stefanova", "Stefanova", "9011115757", "bul. Al.Malinov 1", "0888555555", "*****@*****.**", 3, Specialty.EngineerDesign, Faculty.MF, University.TUSofiya);

            // Testing the ToString() method
            Console.WriteLine("Testing the ToString() method:");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine(firstStudent);
            Console.WriteLine(secondStudent);
            // Testing the GetHashCode() and Equals methods
            Console.WriteLine("Testing the GetHashCode() and Equals() methods:");
            Console.WriteLine(new string('-', 47));
            Console.WriteLine("Result of the Equals() method for the third and the second student: {0}", thirdStudent.Equals(secondStudent));
            Console.WriteLine("First student HashCode: " + firstStudent.GetHashCode());
            Console.WriteLine("Second student HashCode: " + secondStudent.GetHashCode());
            Console.WriteLine("Result of the Equals() method for the hashcodes of the first and the second student: " + firstStudent.GetHashCode().Equals(secondStudent.GetHashCode()));
            Console.WriteLine("Result of the Equals() method for the hashcodes of the third and the second student: " + thirdStudent.GetHashCode().Equals(secondStudent.GetHashCode()));
            Console.WriteLine();
            // Testing the == and != operators
            Console.WriteLine("Testing the == and != operators:");
            Console.WriteLine(new string('-', 32));
            Console.WriteLine("First student == Second student: {0}", firstStudent == secondStudent);
            Console.WriteLine("Second student == Third student: {0}", secondStudent == thirdStudent);
            Console.WriteLine("First student != Second student: {0}", firstStudent != secondStudent);
            Console.WriteLine("Second student != Third student: {0}", secondStudent != thirdStudent);
            Console.WriteLine();
            // Testing the Clone() method
            Console.WriteLine("Testing the Clone() method:");
            Console.WriteLine(new string('-', 27));
            Student copiedStudent = firstStudent.Clone() as Student;
            Console.WriteLine("First student clone == First student: {0}", copiedStudent == firstStudent);
            Console.WriteLine();
            // Testing the CompareTo() method
            Console.WriteLine("Testing the CompareTo() method:");
            Console.WriteLine(new string('-', 31));
            Console.WriteLine("First student compared to the second student: {0}", firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Second student compared to the first student: {0}", secondStudent.CompareTo(firstStudent));
            Console.WriteLine("Cloned student compared to the first student: {0}", copiedStudent.CompareTo(firstStudent));
        }
Ejemplo n.º 19
0
        public static void Main()
        {
            var peshoStudent = new Student("Pesho", "Stamatov", "Peshev", 1234, "Address", "0899635423", "*****@*****.**", 2, University.MU, Faculties.Dental, Specialities.Medicine);

            var joroStudent = new Student("Joro", "Georgiev", "Peshev", 2234, "Address", "0899635423", "*****@*****.**", 4, University.TU, Faculties.Telecomunications, Specialities.Tellecomunications);

            Console.WriteLine(peshoStudent.ToString());                     // Task 1
            Console.WriteLine("HashCode: {0}", peshoStudent.GetHashCode()); // Task 1
            Console.WriteLine(peshoStudent.Equals(joroStudent));            // Task 1
            Console.WriteLine(peshoStudent == joroStudent);
            Console.WriteLine(peshoStudent != joroStudent);

            var cloneStudent = peshoStudent.Clone(); // Task 2

            Console.WriteLine(new string('-', 50));
            Console.WriteLine(cloneStudent.ToString());

            Console.WriteLine(peshoStudent.CompareTo(joroStudent)); // Task 3
        }
Ejemplo n.º 20
0
        public static void Main()
        {
            var student        = new Student("Ivan", "Ivanov", "Draganov", "353406", "Sofia", "0888256859", "*****@*****.**", 3, University.TUGabrovo, Specialty.AIUT, Faculty.FEA);
            var otherStudent   = new Student("Ivan", "Peshov", "Peshovski", "352789", "Plovdiv", "+359857457412", "*****@*****.**", 3, University.TUSofia, Specialty.AIUT, Faculty.FEA);
            var anotherStudent = new Student("Asen", "Atanasov", "Petkov", "345879", "Burgas", "0889789888", "*****@*****.**", 2, University.TUGabrovo, Specialty.CST, Faculty.FEA);

            //Equals()
            Console.WriteLine(student.Equals(otherStudent));

            //ToString()
            Console.WriteLine(student);

            //GetHashCode()
            Console.WriteLine(student.GetHashCode());
            Console.WriteLine(otherStudent.GetHashCode());

            //== and !=
            Console.WriteLine(student == otherStudent);
            Console.WriteLine(student != otherStudent);


            //Problem 2
            var clonedStudent = (Student)student.Clone();

            Console.WriteLine("\nProblem 2");

            Console.WriteLine(clonedStudent);

            //Problem 3
            var students = new SortedSet <Student>();

            students.Add(student);
            students.Add(otherStudent);
            students.Add(anotherStudent);

            Console.WriteLine("\nProblem 3");

            foreach (var st in students)
            {
                Console.WriteLine(st);
            }
        }
Ejemplo n.º 21
0
        static void Main()
        {
            // Student Tests!
            Console.WriteLine("Student Tests:");
            Student firstStudent  = new Student("Pesho", "Georgiev", "Ivanov", 656123, "Liulin 5", "*****@*****.**", "0885235465", "IT", SpecialtyType.Cooking, UniversityType.Cambridge, FacultyType.Medicine);
            Student secondStudent = new Student("Stela", "Ivanova", "Petrova", 659876, "Mall Sofia", "*****@*****.**", "0888123568", "Maths", SpecialtyType.SoftwareEngineering, UniversityType.Oxford, FacultyType.Mathematics);

            var equalStudents = firstStudent == secondStudent;
            var hashCode      = firstStudent.GetHashCode();

            // Testing Equal()
            Console.WriteLine("\nFirst and second student are equal? -> {0}", equalStudents);
            Console.WriteLine(new string('-', 60));

            // Testing GetHashCode()
            Console.WriteLine("Hash code of first student -> " + hashCode);
            Console.WriteLine(new string('-', 60));

            // Printing Student
            Console.WriteLine(firstStudent);
            Console.WriteLine(new string('-', 60));

            // Changing the specialty on the cloning student doesnt affect the original firstStudent
            var firstStudentCloning = firstStudent.Clone() as Student;

            firstStudentCloning.Faculty = FacultyType.Sports;
            Console.WriteLine(firstStudentCloning);

            // Comparing students by first criteria -> Names, then by second criteria -> SS Number
            Console.WriteLine(new string('-', 60));
            Console.WriteLine("Comparisson -> " + firstStudent.CompareTo(secondStudent) + Environment.NewLine);
            Console.WriteLine(new string('-', 60));

            // Person Tests
            Console.WriteLine("Person Tests:");
            Console.WriteLine();
            Person firstPerson  = new Person("Dragoi Blagoev", 5);
            Person secondPerson = new Person("Ivcho");

            Console.WriteLine(firstPerson);
            Console.WriteLine(secondPerson);
        }
Ejemplo n.º 22
0
 static void Main()
 {
     Student student1 = new Student ("Anton", "Dimitrov", "Ivanov", 1497845, "Ul. Briast 13", "099922233", "*****@*****.**", 2, Speciality.Statistic, University.TU, Faculty.Mathemathical);
     Student student2 = new Student("Anton", "Dimitrov", "Ivanov", 1497845, "Ul. Briast 13", "099922233", "*****@*****.**", 2, Speciality.Statistic, University.TU, Faculty.Mathemathical);
     Console.WriteLine("Student1.Equals(Student2) - {0}", student1.Equals(student2));
     student2.FirstName = "Ivan";
     Console.WriteLine("After changes in student 2 - Student1.Equals(Student2) - {0}", student1.Equals(student2));
     Console.WriteLine("student1 == student2 - {0}", student1 == student2);
     Console.WriteLine("student1 != student2 - {0}", student1 != student2);
     Console.WriteLine("Student1 hask code - {0}", student1.GetHashCode());
     Console.WriteLine();
     Console.WriteLine("02.IClonable");
     Console.WriteLine(new string('-', Console.WindowWidth));
     var clone = student1.Clone() as Student;
     Console.WriteLine("Clone of student1");
     Console.WriteLine(clone);
     Console.WriteLine();
     student1.FirstName = "Darin";
     student1.Course = 3;
     student1.Speciality = Speciality.FinancialManagment;
     Console.WriteLine("Student1 after some changes");
     Console.WriteLine(student1);
     Console.WriteLine();
     Console.WriteLine("Cloned student has not changed");
     Console.WriteLine(clone);
     Console.WriteLine();
     Console.WriteLine();
     Console.WriteLine("03.IComparable");
     Console.WriteLine(new string('-', Console.WindowWidth));
     if(student1.CompareTo(student2) > 0)
     {
         Console.WriteLine("student1 < student2");
     }
     else if(student1.CompareTo(student2) < 0)
     {
         Console.WriteLine("student1 > student2");
     }
     else
     {
         Console.WriteLine("student1 = student2");
     }
 }
        static void Main()
        {
            Student first  = new Student("Petar", "Rashov", "Todorov", 0011, "bul. Alexander Malinov 32", "0898674523", "*****@*****.**", "IT", Specialities.ElektronicSystems, Universities.Cambridge, Faculties.Engeneering);
            Student second = new Student("Mitraki", "Desov", "Asenov", 0001, "bul. Vitosha 15", "0887462430", "*****@*****.**", "Robotics", Specialities.RoboSoftware, Universities.MIT, Faculties.Robotics);

            var equalStudents = first == second;
            var hashCode      = first.GetHashCode();

            Console.WriteLine("\nFirst and second student are equal? -> {0}", equalStudents);
            Console.WriteLine("------------------------------");

            Console.WriteLine("Hash code of first student -> " + hashCode);
            Console.WriteLine("------------------------------");

            Console.WriteLine(first);
            Console.WriteLine("------------------------------");

            var firstStudentCloning = first.Clone() as Student;

            firstStudentCloning.Faculty = Faculties.Sports;
            Console.WriteLine(firstStudentCloning);

            Console.WriteLine("------------------------------");
            Console.WriteLine("Comparisson -> " + first.CompareTo(second) + Environment.NewLine);
            Console.WriteLine("------------------------------");

            // Person

            Console.WriteLine("---------------Person----------------");

            var Basti = new Person("Bastian Schweinsteiger", 33);

            Console.WriteLine(Basti);

            var Mani = new Person("Manuel Neuer", 32);

            Console.WriteLine(Mani);

            var JLo = new Person("Jeniffer Lopez");

            Console.WriteLine(JLo);
        }
Ejemplo n.º 24
0
        public static void Main()
        {
            // initaialise two students - the ususal suspects - Pesho and Gosho
            Student pesho = new Student("Pesho", "Peshev", "Peshev", "2036984", "15 Peshova dolina str., Peshov Dol",
                                        "+35988800800", "*****@*****.**", "Nekaf kurs", Specialty.SomeSPecialityOne, University.SomeUniversityOne, Faculty.SomeFacultyOne);

            Student gosho = new Student("Gosho", "Goshev", "Goshev", "3058520", "10 Goshova livada str, Gohotown",
                                        "+35989900900", "*****@*****.**", "Drug kurs", Specialty.SomeSpecialityTwo, University.SomeUniversityTwo, Faculty.SOmeFacultyTwo);

            // Print them to consol to check override of ToString() method
            Console.WriteLine("Pesho");
            Console.WriteLine(pesho);
            Console.WriteLine("\nGosho");
            Console.WriteLine(gosho);

            // Make a deep copy of Gosho
            Student clonedGosho = (Student)gosho.Clone();

            Console.WriteLine("\nCloned gosho:");
            Console.WriteLine(clonedGosho);

            // Change the first name og Cloned Gosho and print it and the original one
            clonedGosho.FirstName = "Izomrud";
            Console.WriteLine("\nCloned gosho with changed first name:");
            Console.WriteLine(clonedGosho);
            Console.WriteLine("\nGosho again to check if the clone is deep:");
            Console.WriteLine(gosho);

            // chesk the overridin of Equal()
            Console.WriteLine("\nCheck Equal gosho ang pesho");
            Console.WriteLine(pesho.Equals(gosho));

            // Print hash codes
            Console.WriteLine("\nPrint hach codes of gosho and pesho:");
            Console.WriteLine(pesho.GetHashCode());
            Console.WriteLine(gosho.GetHashCode());
            Console.WriteLine(clonedGosho.GetHashCode());

            // Compare Gosho to Pesho
            Console.WriteLine("\nPrint result of compare gosho to pesho: ");
            Console.WriteLine(gosho.CompareTo(pesho));
        }
Ejemplo n.º 25
0
        public static void Main()
        {
            var student = new Student("Ivan", "Ivanov", "Draganov", "353406", "Sofia", "0888256859", "*****@*****.**", 3, University.TUGabrovo, Specialty.AIUT, Faculty.FEA);
            var otherStudent = new Student("Ivan", "Peshov", "Peshovski", "352789", "Plovdiv", "+359857457412", "*****@*****.**", 3, University.TUSofia, Specialty.AIUT, Faculty.FEA);
            var anotherStudent = new Student("Asen", "Atanasov", "Petkov", "345879", "Burgas", "0889789888", "*****@*****.**", 2, University.TUGabrovo, Specialty.CST, Faculty.FEA);

            //Equals()
            Console.WriteLine(student.Equals(otherStudent));

            //ToString()
            Console.WriteLine(student);

            //GetHashCode()
            Console.WriteLine(student.GetHashCode());
            Console.WriteLine(otherStudent.GetHashCode());

            //== and !=
            Console.WriteLine(student == otherStudent);
            Console.WriteLine(student != otherStudent);

            //Problem 2
            var clonedStudent = (Student)student.Clone();

            Console.WriteLine("\nProblem 2");

            Console.WriteLine(clonedStudent);

            //Problem 3
            var students = new SortedSet<Student>();

            students.Add(student);
            students.Add(otherStudent);
            students.Add(anotherStudent);

            Console.WriteLine("\nProblem 3");

            foreach (var st in students)
            {
                Console.WriteLine(st);
            }
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            var s = new Student {
                Adress = "Strada", Course = "Curs", Email = "[email protected]", Facultate = Faculties.AC, FirstName = "A", LastName = "B", MidlleName = "C", MobilePhone = 07412123, Specialitate = Specialities.Info, SSN = 1, Universitate = Universities.Cuza
            };
            var s2 = s.Clone();
            var s3 = new Student {
                Adress = "Strada", Course = "Curs", Email = "[email protected]", Facultate = Faculties.AC, FirstName = "B", LastName = "B", MidlleName = "C", MobilePhone = 07412123, Specialitate = Specialities.Info, SSN = 1, Universitate = Universities.Cuza
            };
            // s.Facultate = Faculties.Dentara;
            var b = Equals(s, s3);

            //s.Facultate = Faculties.Dentara;
            if (s == s3)
            {
            }
            var s4 = new Student {
                Adress = "Strada", Course = "Curs", Email = "[email protected]", Facultate = Faculties.AC, FirstName = "B", LastName = "B", MidlleName = "C", MobilePhone = 07412123, Specialitate = Specialities.Info, SSN = 2, Universitate = Universities.Cuza
            };
            var s5 = new Student {
                Adress = "Strada", Course = "Curs", Email = "[email protected]", Facultate = Faculties.AC, FirstName = "B", LastName = "N", MidlleName = "C", MobilePhone = 07412123, Specialitate = Specialities.Info, SSN = 2, Universitate = Universities.Cuza
            };
            var s6 = new Student {
                Adress = "Strada", Course = "Curs", Email = "[email protected]", Facultate = Faculties.AC, FirstName = "A", LastName = "D", MidlleName = "C", MobilePhone = 07412123, Specialitate = Specialities.Info, SSN = 3, Universitate = Universities.Cuza
            };
            var            i     = s.CompareTo(s3);
            List <Student> lista = new List <Student>();

            lista.Add(s);
            lista.Add(s3);
            lista.Add(s4);
            lista.Add(s5);
            lista.Add(s6);
            lista.Sort();
            foreach (var item in lista)
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
Ejemplo n.º 27
0
        /*
         Problem 1: Define a class Student, which contains data about a student – first, middle and last name, SSN,
         permanent address, mobile phone e-mail, course, specialty, university, faculty. Use an enumeration for the specialties,
         universities and faculties.
         Override the standard methods, inherited by System.Object: Equals(), ToString(), GetHashCode() and operators == and !=.
         Problem 2: Add implementations of the ICloneable interface. The Clone() method should deeply copy all object's
         fields into a new object of type Student.
         Problem 3: Implement the IComparable<Student> interface to compare students by names (as first criteria, in
         lexicographic order) and by social security number (as second criteria, in increasing order).
         */
        public static void Main()
        {
            var student = new Student(
                "Pesho",
                "Peshev",
                "Petkov",
                "029338419",
                "23 Elm Street",
                "0885100300",
                "*****@*****.**",
                "Software engineering",
                Speciality.Mathematics,
                University.TechUni,
                Faculty.SF);

            Console.WriteLine(student.ToString());

            var otherStudent = student.Clone();

            Console.WriteLine(otherStudent);
        }
Ejemplo n.º 28
0
        static void Main()
        {
            Student firstStudent = new Student("Ivan", "Doychinov", 3435467234, 2, Specialty.ApplingMath, University.TechnicalUniversity, Faculty.MathematicalFaculty);

            Student secondStudent = new Student("Petar", "Mihov", 3435467234, 2, Specialty.ApplingMath, University.TechnicalUniversity, Faculty.MathematicalFaculty);

            Student thirdStudent = new Student("Ivan", "Doychinov", 3435467234, 2, Specialty.ApplingMath, University.TechnicalUniversity, Faculty.MathematicalFaculty);

            if (firstStudent != secondStudent)  // it is true
                Console.WriteLine("{0} != {1}", firstStudent.FirstName, secondStudent.FirstName);

            if (firstStudent == thirdStudent)  // it is true
                Console.WriteLine("{0} == {1}", firstStudent.FirstName, thirdStudent.FirstName);

            Student deeplyCloned = (Student)firstStudent.Clone();

            Console.WriteLine("\nThe Cloned student is: ");
            Console.WriteLine(deeplyCloned);

            Console.WriteLine(firstStudent.CompareTo(secondStudent));
        }
Ejemplo n.º 29
0
 static void Main(string[] args)
 {
     Student student = new Student(
            "Miro",
            "Peshev",
            "Goshov",
            "5524887456",
            "blv Vitosha 243",
            "0896565689",
            "*****@*****.**",
            "Math and Stuff",
            Speciality.Math,
            University.IIT,
            Faculty.Math);
     Console.WriteLine("to string:" + student.ToString());
     var otherStudent = student.Clone();
     Console.WriteLine("Cloned student to string: " + otherStudent.ToString());
     Console.WriteLine(student == otherStudent);
     Console.WriteLine(student.Equals(student));
     Console.WriteLine(student.Equals(otherStudent));
     Console.WriteLine(student != otherStudent);
 }
Ejemplo n.º 30
0
        public static void Main()
        {
            Student firstSudent = new Student("Pesho", "Ivanov", "Georgiev", 9003177211, "Sofia, № 411 Georgi Kalinov street",
                "0899471511", "*****@*****.**", 4, Specialty.ComputerSciences, University.Birmingham, Faculty.Technology);

            Student secondSudent = new Student("Pesho", "Peshov", "Ivanov", 9003177211, "Sofia, № 411 Georgi Kalinov street",
                "0877415500", "*****@*****.**", 1, Specialty.EarthSciences, University.Lancaster, Faculty.PhysicalSciences);

            Student thirdSudent = new Student("Ivelina", "Stamatova", "Petkovva", 9101114512, "Sofia, № 21 Georgi Kalinov street",
                "0899471511", "*****@*****.**", 3, Specialty.Journalism, University.Harvard, Faculty.HumanitiesSocialSciences);

            Student fourthSudent = new Student("Stamat", "Ivanov", "Stamatov", 9309121411, "Sofia, № 9 Georgi Kalinov street",
                "0899510100", "*****@*****.**", 3, Specialty.BiologicalSciences, University.Durham, Faculty.ClinicalMedicine);

            Console.WriteLine(firstSudent);
            Console.WriteLine("\nAre equals: {0}", firstSudent == secondSudent);
            Console.WriteLine("HashCode: {0}", thirdSudent.GetHashCode());

            Console.WriteLine("Please press a key do clear the console and to continue.");
            Console.ReadKey();
            Console.Clear();

            // Clone student
            var newStudentClone = firstSudent.Clone();

            // Change some thing in the cloning
            (newStudentClone as Student).FirstName = "Doncho";
            (newStudentClone as Student).LastName = "Petkov";

            Console.WriteLine("The cloning with some changes:\n");
            Console.WriteLine(newStudentClone);

            Console.WriteLine("The original:\n");
            Console.WriteLine(firstSudent);

            // Using CompareTo
            Console.WriteLine("Compare two student by names and SSN: {0}", firstSudent.CompareTo(secondSudent));
        }
Ejemplo n.º 31
0
        static void Main()
        {
            Student firstStudent = new Student("Ivan", "Petrov", "Ivanov", 456789,
                                               "Burgas, ul. Ferdinandova", "088456789", "*****@*****.**", 3,
                                               Specialty.InformationTechnology, University.TechnicalUniversity, Faculty.InformationFac);
            Student secondStudent = new Student("Petar", "Petrov", "Ivanov", 123456,
                                                "Burgas, ul. Carigradska", "082342356", "*****@*****.**", 4,
                                                Specialty.Mathematics, University.SofiaUniversity, Faculty.MathematicsFac);
            Student thirdStudent = new Student("Wania", "Petrova", "Dimova", 359456,
                                               "Burgas, ul. Hristo Botev", "082342356", "*****@*****.**", 1,
                                               Specialty.SoftwareEngineering, University.TechnicalUniversity, Faculty.SoftwareFac);

            Console.WriteLine("-------------------------------------");
            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine("-------------------------------------");
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine("-------------------------------------");
            Console.WriteLine(thirdStudent.ToString());
            Console.WriteLine("-------------------------------------");

            Console.WriteLine(firstStudent == secondStudent);
            Console.WriteLine(firstStudent != thirdStudent);

            Console.WriteLine(firstStudent.Equals(secondStudent));
            Console.WriteLine(thirdStudent.Equals(thirdStudent));

            Student firstStudentCopy = firstStudent.Clone();

            Console.WriteLine("-------------------------------------");
            Console.WriteLine(firstStudentCopy);
            firstStudentCopy.Specialty  = Specialty.SoftwareEngineering;
            firstStudentCopy.University = University.TechnicalUniversity;
            firstStudentCopy.Faculty    = Faculty.SoftwareFac;
            Console.WriteLine("-------------------------------------");
            Console.WriteLine(firstStudent);
            Console.WriteLine("-------------------------------------");
            Console.WriteLine(firstStudentCopy);
        }
        public static void Main()
        {
            Student firstSudent = new Student("Pesho", "Ivanov", "Georgiev", 9003177211, "Sofia, № 411 Georgi Kalinov street",
                                              "0899471511", "*****@*****.**", 4, Specialty.ComputerSciences, University.Birmingham, Faculty.Technology);

            Student secondSudent = new Student("Pesho", "Peshov", "Ivanov", 9003177211, "Sofia, № 411 Georgi Kalinov street",
                                               "0877415500", "*****@*****.**", 1, Specialty.EarthSciences, University.Lancaster, Faculty.PhysicalSciences);

            Student thirdSudent = new Student("Ivelina", "Stamatova", "Petkovva", 9101114512, "Sofia, № 21 Georgi Kalinov street",
                                              "0899471511", "*****@*****.**", 3, Specialty.Journalism, University.Harvard, Faculty.HumanitiesSocialSciences);

            Student fourthSudent = new Student("Stamat", "Ivanov", "Stamatov", 9309121411, "Sofia, № 9 Georgi Kalinov street",
                                               "0899510100", "*****@*****.**", 3, Specialty.BiologicalSciences, University.Durham, Faculty.ClinicalMedicine);

            Console.WriteLine(firstSudent);
            Console.WriteLine("\nAre equals: {0}", firstSudent == secondSudent);
            Console.WriteLine("HashCode: {0}", thirdSudent.GetHashCode());

            Console.WriteLine("Please press a key do clear the console and to continue.");
            Console.ReadKey();
            Console.Clear();

            // Clone student
            var newStudentClone = firstSudent.Clone();

            // Change some thing in the cloning
            (newStudentClone as Student).FirstName = "Doncho";
            (newStudentClone as Student).LastName  = "Petkov";

            Console.WriteLine("The cloning with some changes:\n");
            Console.WriteLine(newStudentClone);

            Console.WriteLine("The original:\n");
            Console.WriteLine(firstSudent);

            // Using CompareTo
            Console.WriteLine("Compare two student by names and SSN: {0}", firstSudent.CompareTo(secondSudent));
        }
        static void Main()
        {
            var firstStudent = new Student("Gosho", "Brigadirov", "Kirov", 554755, "2 Pencho street", "+3598875423664",
                "*****@*****.**", 5, Specialitiy.Engineering, University.TehnicalUniversity, Faculty.Mathematic);
            var secondStudent = new Student("Evdokiq", "Gusheva", "Musheva", 558899, "3 Nanadolnishte blv.", "029408751",
                "*****@*****.**", 4, Specialitiy.Biology, University.UNSS, Faculty.Biologic);
            Console.WriteLine(new string('*', 40));
            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine();
            Console.WriteLine("{0} hash code is {1}",firstStudent.FirstName, firstStudent.GetHashCode());
            Console.WriteLine("{0} hash code is {1}",secondStudent.FirstName ,secondStudent.GetHashCode());

            Console.WriteLine(new string('*', 40));
            Console.WriteLine("Coping:");
            Console.WriteLine(new string('*', 40));
            var AntoanCopy = firstStudent.Clone();
            Console.WriteLine(AntoanCopy);

            Console.WriteLine(new string('*', 40));
            Console.WriteLine("Comparing");
            Console.WriteLine(new string('*', 40));
            Console.WriteLine(firstStudent.CompareTo(secondStudent));
        }
Ejemplo n.º 34
0
        public static void Main()
        {
            Student pesho = new Student("pesho","pehov","goshov",555,"Ul Marica","53646546","*****@*****.**",4,UniversityEnum.TechnicalUniversity,FacultyEnum.Mathematics,SpecialtyEnum.IT);
            Student secondPesho = new Student("pesho", "pehov", "goshov", 555, "Ul Marica", "53646546", "*****@*****.**", 4, UniversityEnum.TechnicalUniversity, FacultyEnum.Mathematics, SpecialtyEnum.IT);
            Student gosho = new Student("gosho", "pehov", "goshov", 5453555, "Ul Rarica", "53644456546", "*****@*****.**", 4, UniversityEnum.TechnicalUniversity, FacultyEnum.Mathematics, SpecialtyEnum.IT);
            Console.WriteLine(pesho.ToString());

            if (pesho==secondPesho)
            {
                Console.WriteLine("Operator == works fine!");
            }
            if (pesho!=secondPesho)
            {
                Console.WriteLine("Doesn't work");
            }
            else
            {
                Console.WriteLine("Operator != works fine!");
            }

            Console.WriteLine();
            Console.Write("Equals method: ");
            Console.WriteLine(pesho.Equals(secondPesho));
            Console.WriteLine();
            Console.Write("Pesho get hash code method: ");
            Console.WriteLine(pesho.GetHashCode());
            Console.Write("Gosho get hash code method: ");
            Console.WriteLine(gosho.GetHashCode());
            Console.WriteLine();
            Console.WriteLine("Copy of pesho:");

            Student peshoCopy = pesho.Clone() as Student;
            Console.WriteLine(peshoCopy);

            Console.Write("Pesho compare to copy of pesho: ");
            Console.WriteLine(pesho.CompareTo(peshoCopy));
        }
Ejemplo n.º 35
0
        static void Main(string[] args)
        {
            Student student = new Student(
                "Miro",
                "Peshev",
                "Goshov",
                "5524887456",
                "blv Vitosha 243",
                "0896565689",
                "*****@*****.**",
                "Math and Stuff",
                Speciality.Math,
                University.IIT,
                Faculty.Math);

            Console.WriteLine("to string:" + student.ToString());
            var otherStudent = student.Clone();

            Console.WriteLine("Cloned student to string: " + otherStudent.ToString());
            Console.WriteLine(student == otherStudent);
            Console.WriteLine(student.Equals(student));
            Console.WriteLine(student.Equals(otherStudent));
            Console.WriteLine(student != otherStudent);
        }
Ejemplo n.º 36
0
        public static void Main(string[] args)
        {
            Person pesho = new Person("Peter");

            Console.WriteLine(pesho);

            var mincho = new Student(
                "Mincho",
                "Hristov",
                "Petrov",
                323453,
                "Sofia",
                0888888888,
                "*****@*****.**",
                2,
                Specialty.Engines,
                University.TUSofia,
                Faculty.ComputerScience);

            var penka = new Student(
                "Penka",
                "Slavova",
                "Litova",
                323453,
                "Varna",
                0888123456,
                "*****@*****.**",
                2,
                Specialty.PlasticSurgery,
                University.MedicalUniversity,
                Faculty.Chemistry);

            Student pencho = new Student(
                "Mincho",
                "Hristov",
                "Petrov",
                323453,
                "Sofia",
                0888765488,
                "*****@*****.**",
                5,
                Specialty.HumanBehavior,
                University.UniSofia,
                Faculty.Psychology);

            Console.WriteLine("Mincho equals pencho: " + mincho.Equals(pencho));
            Console.WriteLine("Mincho == pencho: " + (mincho == pencho));
            Console.WriteLine("Mincho != pencho: " + (mincho != pencho));

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(pencho);

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(mincho);

            Console.WriteLine(Environment.NewLine);
            var tempStudent = mincho.Clone() as Student;
            Console.WriteLine("Reference equals tempStudent and mincho: " + object.ReferenceEquals(tempStudent.MiddleName, mincho.MiddleName));

            tempStudent.MiddleName = "Gosho";
            mincho.MiddleName = "Mincho 2";
            Console.WriteLine(tempStudent.MiddleName);
            Console.WriteLine(mincho.MiddleName); 

            Console.WriteLine(pencho.CompareTo(mincho));
        }
Ejemplo n.º 37
0
        static void Main()
        {
            var student1 = new Student()
            {
                FirstName = "Ivan",
                MiddleName = "Atanasov",
                LastName = "Georgiev",
                SSN = 940329010526,
                Address = "Sofia, Studentski Grad",
                Phone = "+359878224387",
                Email = "*****@*****.**",
                Course = 2,
                Specialty = Specialty.InformationSystems,
                University = University.SU,
                Faculty = Faculty.FMI
            };

            var student2 = new Student()
            {
                FirstName = "Ivaylo",
                MiddleName = "Asenov",
                LastName = "Todorov",
                SSN = 920513010948,
                Address = "Sofia, Lulin",
                Phone = "+359878564389",
                Email = "*****@*****.**",
                Course = 4,
                Specialty = Specialty.Biology,
                University = University.MedicalUniversity,
                Faculty = Faculty.BiologyDepartment
            };

            //check for equals SSN
            Console.WriteLine("student1 == student2: {0}", student1 == student2);
            Console.WriteLine("student1 != student2: {0}", student1 != student2);
            Console.WriteLine();

            //Clone() return object and cast is nessesary
            Student newStudent = (Student)student1.Clone();
            newStudent.FirstName = "Petar";
            Console.WriteLine(student1);
            Console.WriteLine();
            Console.Write("This is test for Clone() method. New object doesn't change the original object:");
            Console.WriteLine(newStudent);
            Console.WriteLine();
            Console.WriteLine(student2);
            Console.WriteLine();

            Console.WriteLine("Test CompareTo() method:");
            int resultCompare = student1.CompareTo(student2);
            if (resultCompare == 0)
            {
                //this can not happent because if three names is the same we finaly compare to SSN which in real life is unique
                Console.WriteLine("student1 = student2");
            }
            else if (resultCompare < 0)
            {
                //the passed object is bigger of this
                //compare to one of three names
                Console.WriteLine("student1 < student2");
            }
            else
            {
                Console.WriteLine("student1 > student2");
            }
        }
Ejemplo n.º 38
0
        static void Main()
        {
            var student1 = new Student()
            {
                FirstName  = "Ivan",
                MiddleName = "Atanasov",
                LastName   = "Georgiev",
                SSN        = 940329010526,
                Address    = "Sofia, Studentski Grad",
                Phone      = "+359878224387",
                Email      = "*****@*****.**",
                Course     = 2,
                Specialty  = Specialty.InformationSystems,
                University = University.SU,
                Faculty    = Faculty.FMI
            };

            var student2 = new Student()
            {
                FirstName  = "Ivaylo",
                MiddleName = "Asenov",
                LastName   = "Todorov",
                SSN        = 920513010948,
                Address    = "Sofia, Lulin",
                Phone      = "+359878564389",
                Email      = "*****@*****.**",
                Course     = 4,
                Specialty  = Specialty.Biology,
                University = University.MedicalUniversity,
                Faculty    = Faculty.BiologyDepartment
            };

            //check for equals SSN
            Console.WriteLine("student1 == student2: {0}", student1 == student2);
            Console.WriteLine("student1 != student2: {0}", student1 != student2);
            Console.WriteLine();

            //Clone() return object and cast is nessesary
            Student newStudent = (Student)student1.Clone();

            newStudent.FirstName = "Petar";
            Console.WriteLine(student1);
            Console.WriteLine();
            Console.Write("This is test for Clone() method. New object doesn't change the original object:");
            Console.WriteLine(newStudent);
            Console.WriteLine();
            Console.WriteLine(student2);
            Console.WriteLine();

            Console.WriteLine("Test CompareTo() method:");
            int resultCompare = student1.CompareTo(student2);

            if (resultCompare == 0)
            {
                //this can not happent because if three names is the same we finaly compare to SSN which in real life is unique
                Console.WriteLine("student1 = student2");
            }
            else if (resultCompare < 0)
            {
                //the passed object is bigger of this
                //compare to one of three names
                Console.WriteLine("student1 < student2");
            }
            else
            {
                Console.WriteLine("student1 > student2");
            }
        }
Ejemplo n.º 39
0
        public static void Main(string[] args)
        {
            Person pesho = new Person("Peter");

            Console.WriteLine(pesho);

            var mincho = new Student(
                "Mincho",
                "Hristov",
                "Petrov",
                323453,
                "Sofia",
                0888888888,
                "*****@*****.**",
                2,
                Specialty.Engines,
                University.TUSofia,
                Faculty.ComputerScience);

            var penka = new Student(
                "Penka",
                "Slavova",
                "Litova",
                323453,
                "Varna",
                0888123456,
                "*****@*****.**",
                2,
                Specialty.PlasticSurgery,
                University.MedicalUniversity,
                Faculty.Chemistry);

            Student pencho = new Student(
                "Mincho",
                "Hristov",
                "Petrov",
                323453,
                "Sofia",
                0888765488,
                "*****@*****.**",
                5,
                Specialty.HumanBehavior,
                University.UniSofia,
                Faculty.Psychology);

            Console.WriteLine("Mincho equals pencho: " + mincho.Equals(pencho));
            Console.WriteLine("Mincho == pencho: " + (mincho == pencho));
            Console.WriteLine("Mincho != pencho: " + (mincho != pencho));

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(pencho);

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(mincho);

            Console.WriteLine(Environment.NewLine);
            var tempStudent = mincho.Clone() as Student;

            Console.WriteLine("Reference equals tempStudent and mincho: " + object.ReferenceEquals(tempStudent.MiddleName, mincho.MiddleName));

            tempStudent.MiddleName = "Gosho";
            mincho.MiddleName      = "Mincho 2";
            Console.WriteLine(tempStudent.MiddleName);
            Console.WriteLine(mincho.MiddleName);

            Console.WriteLine(pencho.CompareTo(mincho));
        }