public object Clone()
        {
            Student temp = new Student(this.NameFirst, this.NameMiddle, this.NameLast, this.SSN, this.Address
                , this.Mobile, this.EMail, this.University, this.Faculty, this.Speciality, this.Course);

            return temp;
        }
 static void Main(string[] args)
 {
     Student student = new Student("Ivan", "Ivanov", "Ivanov");
     University uni = new University(University.Universities.Stanford, University.Faculties.Physics, University.Specialties.Physicist);
     student.AddUnivercity(uni);
     Console.WriteLine(student);
 }
        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));
        }
        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()
        {
            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(string[] args)
        {
            Student firstStudent = new Student("Boncho", "Bonchov", "Bonchoto", 13202733, "Ulica nqkva si 33", "+359 8824324234",
                "*****@*****.**", 4, Specialties.Programming,
                University.SofiaUniversity, Faculty.Informatics);

            Student secondStudent = new Student("Spartak", "Spartakiev", "Spartakov", 12224956, "Ulica nqkva si 34", "+359 8854545454",
                "*****@*****.**", 4, Specialties.Art,
                University.NBU, Faculty.Arts);

            Student thirdStudent = new Student("Boncho", "Bonchov", "Bonchoto", 13202733, "Ulica nqkva si 33", "+359 8824324234",
                "*****@*****.**", 4, Specialties.Programming,
                University.SofiaUniversity, Faculty.Informatics);

            Console.WriteLine(firstStudent + "\n");
            Console.WriteLine(secondStudent + "\n");
            Console.WriteLine("Students are equals: " + firstStudent.Equals(secondStudent) + "\n");
            Console.WriteLine("Students are equals: " + firstStudent.Equals(thirdStudent) + "\n");
            Console.WriteLine("Hash code student one: {0}\nHash code student two: {1}\n.",
                firstStudent.GetHashCode(), secondStudent.GetHashCode());
            Console.WriteLine("Equals operator \"==\": {0}\n", firstStudent == thirdStudent);
            Console.WriteLine("Equals operator \"!=\": {0}\n", firstStudent != thirdStudent);
        }
 public object Clone()
 {
     var newSt = new Student()
     {
         FirstName = this.FirstName,
         MiddleName = this.MiddleName,
         LastName = this.LastName,
         SSN = this.SSN,
         PermanentAddress = this.PermanentAddress,
         MobilePhone = this.MobilePhone,
         Email = this.Email,
         Course = this.Course,
         Specialty = this.Specialty,
         University = this.University,
         Faculty = this.Faculty
     };
     return newSt;
 }
 public object Clone()
 {
     Student temp = new Student(this.FirstName, this.MiddleName, this.LastName);
     temp.AddUnivercity(uni);
     return temp;
 }
Exemple #11
0
 static void Main(string[] args)
 {
     Student gosho = new Student();
 }
        public object Clone()
        {
            Student temp = new Student(this.FirstName, this.MiddleName,
                this.LastName, this.SSN, this.Address, this.PhoneNumber, this.Email, this.Course, this.specialities, this.University, this.Faculty);

            return temp;
        }
        // Problem 2
        public object Clone()
        {
            Student originalStudent = this;
            Student newStudent = new Student(originalStudent.FirstName, originalStudent.MiddleName, originalStudent.LastName,
                                originalStudent.SSNnumber,originalStudent.Adress,originalStudent.MobilePhone, originalStudent.Email,
                                originalStudent.Course, originalStudent.University, originalStudent.Specialty, originalStudent.Faculty);

            return newStudent;  // Deep clone
        }