static void Main() { Student FirstStudent = new Student("Ivan", "Ivanov", 12154545, Specialty.Informatics, University.SofiaUniversity, Faculty.Mathematics); Student SecontStudent = new Student("Georgi", "Georgiev", 121545545, Specialty.Mathematics, University.SofiaUniversity, Faculty.Mathematics); Student ThirtStudent = new Student("Ivan", "Ivanov", 12154545, Specialty.SoftwareEngineering, University.TehnicalUniversity, Faculty.Informatics, "second", "MiddleOfNothing St", "0897456123", "*****@*****.**", "Georgiev"); Console.WriteLine("Is student equals:"); Console.WriteLine(FirstStudent == SecontStudent); Console.WriteLine(FirstStudent == ThirtStudent); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Compare two students"); Console.WriteLine(FirstStudent.CompareTo(ThirtStudent)); Console.WriteLine(); Console.WriteLine("Data for student:"); Console.WriteLine(ThirtStudent.ToString()); Console.WriteLine(); Console.WriteLine("HashCode:"); Console.WriteLine(FirstStudent.GetHashCode()); Console.WriteLine(SecontStudent.GetHashCode()); }
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(); }
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)); }
public static void Main() { Student firstStudent = new Student("Stamat", "Stamatov", "Stamatev", "1112131415", "StudentskiCity", "0888112233", "*****@*****.**", 1, Specialty.Literature, University.SofiaUniversity, Faculty.Literature); 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("Oh", "Kotio", "Kotev", "12455623125", "Address", "0888765432", "*****@*****.**", 2, Specialty.Chemistry, University.SofiaUniversity, Faculty.Physics); 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)); }
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)); }
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)); }
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; }
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)); }
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)); }
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)); }
static void Main() { Student Pesho = new Student("Pesho", "Petrov", "Petrov", 12546, "Sofia", "+356 558 566 552", "*****@*****.**"); Pesho.UniversityInf(Student.EnumUniversity.SofiaUniversity, 3, Student.EnumFaculty.MatematicaAndInformatica, Student.EnumSpeciality.MatematicaAndInformatica); Console.WriteLine(Pesho.GetHashCode()); Student Gosho = new Student("Georgi", "Georgiev", "Stanchev", 536312, "Varna", "+245 526 665 523", "*****@*****.**"); Gosho.UniversityInf(Student.EnumUniversity.VTU, 4, Student.EnumFaculty.Medicine, Student.EnumSpeciality.Dentist); Console.WriteLine(Gosho.GetHashCode()); Console.WriteLine(Pesho); Console.WriteLine(Gosho); Console.WriteLine(Pesho==Gosho); Console.WriteLine(Pesho.Equals(Pesho)); Console.WriteLine(Pesho.Equals(Gosho)); Console.WriteLine(Pesho!=Gosho); }
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)); }
static void Main() { Student Pesho = new Student("Pesho", "Petrov", "Petrov", 12546, "Sofia", "+356 558 566 552", "*****@*****.**"); Pesho.UniversityInf(Student.EnumUniversity.SofiaUniversity, 3, Student.EnumFaculty.MatematicaAndInformatica, Student.EnumSpeciality.MatematicaAndInformatica); Console.WriteLine(Pesho.GetHashCode()); Student Gosho = new Student("Georgi", "Georgiev", "Stanchev", 536312, "Varna", "+245 526 665 523", "*****@*****.**"); Gosho.UniversityInf(Student.EnumUniversity.VTU, 4, Student.EnumFaculty.Medicine, Student.EnumSpeciality.Dentist); Console.WriteLine(Gosho.GetHashCode()); Console.WriteLine(Pesho); Console.WriteLine(Gosho); Console.WriteLine(Pesho == Gosho); Console.WriteLine(Pesho.Equals(Pesho)); Console.WriteLine(Pesho.Equals(Gosho)); Console.WriteLine(Pesho != Gosho); }
static void Main(string[] args) { Student student = new Student("Jhon", "M", "Jakson", 10002922, "Telerik", "+359 885", "*****@*****.**"); student.FillUniversityInfo(Student._University.SofiaUniversity, 4, Student._Faculty.Mathematics, Student._Speciality.IT); Console.WriteLine(student.GetHashCode()); Student student2 = new Student("Mark", "S", "Morison", 10034222, "Telerik", "+359 883", "*****@*****.**"); student2.FillUniversityInfo(Student._University.TechnicalUniversity, 4, Student._Faculty.Mathematics, Student._Speciality.IT); Console.WriteLine(student2.GetHashCode() + Environment.NewLine); Console.WriteLine(student); Console.WriteLine(student2); Console.WriteLine(student == student2); Console.WriteLine(student.Equals(student)); Console.WriteLine(student.Equals(student2)); Console.WriteLine(student != student2); }
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"); } }
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 }
public static void Main() { Console.WriteLine("01. Student Class \n02. ICloneable \n03. IComparable"); Console.WriteLine(new string('-', 20)); Student firstStudent = new Student( "Jake", "Jacob", "Jackson", "123456789", "Str. 8, Bld. 2", "4412849222", "*****@*****.**", "Biotechnology ", SpecialtyType.InternalMedicine, UniversityType.CardiffUniversity, FacultyType.Medical); Student secondStudent = new Student( "Stephen", "Lee", "Manning", "123456788", "Str. 87, Ent. 3", "4471494602", "*****@*****.**", "Advanced Photography", SpecialtyType.PhotoJournalism, UniversityType.UniversityOfCalifornia, FacultyType.Journalism); Console.WriteLine("Compare: " + firstStudent.CompareTo(secondStudent) + "\n"); Console.WriteLine("First Student Hashcode: " + firstStudent.GetHashCode()); Console.WriteLine("Second Student Hashcode: " + secondStudent.GetHashCode() + "\n"); Console.WriteLine("04. Person Class"); Console.WriteLine(new string('-', 20)); var firstPerson = new Person("Mihael"); var secondPerson = new Person("Gosho", 12); Console.WriteLine(firstPerson + "\n"); Console.WriteLine(secondPerson); }
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); } }
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); }
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); }
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)); }
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); } }
static void Main() { Student student1 = new Student("Gosho", "Patkan", "Siliminski", "Sliven", "08967745", "*****@*****.**", "C#", SpecialityType.CSharpDev, UniversityType.Softuni, FacultyType.Three); Student student2 = new Student("Gosho", "Patkan", "Siliminski", "Sliven", "08967745", "*****@*****.**", "C#", SpecialityType.CSharpDev, UniversityType.Softuni, FacultyType.Three); Console.WriteLine(student1.GetHashCode()); Console.WriteLine(student1 == student2); // Student copy = (Student)student1.Clone(); // // Console.WriteLine(student1); // Console.WriteLine(copy); // // copy.FirstName = "asdasd"; // // Console.WriteLine(student1); // Console.WriteLine(copy); Console.WriteLine(student1.CompareTo(student2)); }
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)); }
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)); }
static void Main() { Student FirstStudent =new Student("Ivan", "Ivanov", 12154545, Specialty.Informatics , University.SofiaUniversity, Faculty.Mathematics ); Student SecontStudent = new Student("Georgi", "Georgiev", 121545545, Specialty.Mathematics, University.SofiaUniversity, Faculty.Mathematics); Student ThirtStudent = new Student("Ivan", "Ivanov", 12154545, Specialty.SoftwareEngineering, University.TehnicalUniversity, Faculty.Informatics, "second", "MiddleOfNothing St", "0897456123", "*****@*****.**", "Georgiev" ); Console.WriteLine("Is student equals:"); Console.WriteLine(FirstStudent == SecontStudent); Console.WriteLine(FirstStudent==ThirtStudent); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Compare two students"); Console.WriteLine(FirstStudent.CompareTo(ThirtStudent)); Console.WriteLine(); Console.WriteLine("Data for student:"); Console.WriteLine(ThirtStudent.ToString()); Console.WriteLine(); Console.WriteLine("HashCode:"); Console.WriteLine(FirstStudent.GetHashCode()); Console.WriteLine(SecontStudent.GetHashCode()); }