static void Main() { var studentMaria = new Student("Maria", "Petrova","985112", 3, Specialty.BiologyTeacher, University.SofiaUneversity, Faculty.Biology); var studentPesho = new Student("Pesho", "Peshev", "159876", 4, Specialty.SoftwareEngineer, University.Technical, Faculty.Electronics); var otherPesho = studentPesho.Clone() as Student; Console.WriteLine("Compare Pesho and otherPesho:"); Console.WriteLine("Equal: "+ studentPesho.Equals(otherPesho)); Console.Write("==: "); Console.WriteLine( studentPesho == otherPesho); Console.Write("!=: "); Console.WriteLine(studentPesho != otherPesho); Console.WriteLine(); Console.WriteLine("Compare Pesho and Maria:"); Console.WriteLine("Equal: " + studentPesho.Equals(studentMaria)); Console.Write("==: "); Console.WriteLine(studentPesho == studentMaria); Console.Write("!=: "); Console.WriteLine(studentPesho != studentMaria); Console.WriteLine(); otherPesho.SSN = "546549"; Console.WriteLine("Original Pesho:\n" +studentPesho.ToString()); Console.WriteLine("Cloned Pesho:\n"+otherPesho.ToString()); Console.WriteLine("Compairing Pesho and otherPesho " +studentPesho.CompareTo(otherPesho)); Console.WriteLine("Compare Pesho and otherPesho:"); //Console.WriteLine("Equal: " + studentPesho.Equals(otherPesho)); Console.Write("==: "); //Console.WriteLine(studentPesho == otherPesho); Console.Write("!=: "); //Console.WriteLine(studentPesho != otherPesho); Console.WriteLine(); }
static void Main(string[] args) { Person person = new Person("Viorela", null); Person person1 = new Person("Alex", 26); Console.WriteLine(person); Console.WriteLine(person1); //public Student(string FirstName, string MiddleName, string Lastname, ulong SSN, ulong Mobile, string Adress, string email, string course, University university, Faculty faculty, Specialty specialty) Student student1 = new Student("Hariga", "Elena", "Viorela", 213223123, 741669147, "Nicolae Iorga", "*****@*****.**", "Math", University.AlexandruIoanCuza, Faculty.BusinessAdministration, Specialty.BusinessAdministrationSystem); Student student2 = new Student("Budianu", "Viorela", "Elena", 213223123, 741669147, "Nicolae Iorga", "*****@*****.**", "Math", University.AlexandruIoanCuza, Faculty.BusinessAdministration, Specialty.BusinessAdministrationSystem); Console.WriteLine("First student equal to second student? {0}", Student.Equals(student1, student2)); Console.WriteLine("First student == second student? {0}", student1 == student2); Console.WriteLine("Firs student != second student? {0}", student1 != student2); Console.WriteLine(); Student student = new Student("Budianu", "Viorela", "Elena", 213223123, 741669147, "Nicolae Iorga", "*****@*****.**", "Math", University.AlexandruIoanCuza, Faculty.BusinessAdministration, Specialty.BusinessAdministrationSystem); Console.WriteLine("First student equal to third student? {0}", Student.Equals(student1, student)); Console.WriteLine("First student == third student? {0}", student1 == student); Console.WriteLine("First student != third student? {0}", student1 != student); Console.WriteLine(); Student s = student.Clone(); Console.WriteLine(student + "++++++++++\n" + s); Console.WriteLine(student.CompareTo(s)); Console.WriteLine(student.CompareTo(student1)); Console.WriteLine($"HasCode for s (cloned) - {s.GetHashCode()}\nHasCode for student - {student.GetHashCode()}"); }
static void Main(string[] args) { Student st = new Student("Pesho", "Goshov", "Ivanov", "9110111245", "Bobovdol, Slaveikov st 10", "0888-88-88-88", "*****@*****.**", "3", Universities.UNWE, Faculties.Informatics, Specialties.BusinessInformatics); Console.WriteLine(st); Student st2 = st.Clone(); Console.WriteLine(st2); }
public static void Main(string[] args) { Student firstStudent = new Student( "Pesho", "Peshov", "Peshov", 12134314, "some address", "+359888 888 888", "*****@*****.**", UniversityEnum.TechnicalUniversity, FacultyEnum.FTK, SpecialtyEnum.TK, CourseEnum.First); Student testEqualStudent = new Student( "Pesho", "Peshov", "Peshov", 12134314, "some address", "+359888 888 888", "*****@*****.**", UniversityEnum.TechnicalUniversity, FacultyEnum.FTK, SpecialtyEnum.TK, CourseEnum.First); Student secondStudent = new Student( "Gosho", "Goshov", "Goshov", 12134315, "another address", "+359888 999 999", "*****@*****.**", UniversityEnum.TelericAcademy, FacultyEnum.Ninja, SpecialtyEnum.TelericAcademyNinja, CourseEnum.Second); Console.WriteLine("First student equals second student: {0}", firstStudent.Equals(secondStudent)); Console.WriteLine("First student == test equal student student: {0}", firstStudent == testEqualStudent); Console.WriteLine("\nStudent.ToString():\n{0}", firstStudent.ToString()); Student clonedStudent = (Student)secondStudent.Clone(); Console.WriteLine("Deep cloned student:\n{0}", clonedStudent.ToString()); Console.WriteLine("First student compared to second student: {0}", firstStudent.CompareTo(secondStudent)); Console.WriteLine("Second student compared to cloned student: {0}", secondStudent.CompareTo(clonedStudent)); Console.WriteLine("Second student compared to first student: {0}", secondStudent.CompareTo(firstStudent)); }
public static void TestStudentClass() { var ivanStudent = new Student( "Ivan", "Ivanov", "Ivanov", "111215439", "Tsar Ivan Asen II - Sofia", "0899456782", "vankata_seksipich", 3, Specialty.AppliedMathematics, University.TechnicalUniversity, Faculty.Mathematics); var ivailoStudent = new Student( "Ivailo", "Petrov", "Ivanov", "111215114", "Shiroka - Sofia", "093651104", "ivo.andonov33", 3, Specialty.DentalMedicine, University.Harvard, Faculty.Medicine); // printing ivan information to check the ToString() method implementation Console.WriteLine(ivanStudent); Console.WriteLine("=================="); // getting ivailoStudent hashCode to chek the GetHashCode() method implementation Console.WriteLine("ivailoStudent hashcode: {0}", ivailoStudent.GetHashCode()); // checkinng the == and != operators by comapring the two students Console.WriteLine("Are students equal: {0}", ivailoStudent == ivanStudent); // Console.WriteLine("Are students equal: {0}", ivailoStudent == (Student)ivailoStudent.Clone()); Console.WriteLine("Are students not equal: {0}", ivailoStudent != ivanStudent); // testing the CompareTo method implementation Console.WriteLine("CompareTo() result: {0}", ivailoStudent.CompareTo(ivanStudent)); Console.WriteLine("============"); // testing the clone method var cloneIvan = (Student)ivanStudent.Clone(); Console.WriteLine("Cloned student info:"); Console.WriteLine(cloneIvan); Console.WriteLine("ivanStudent and clone object of ivanStudent have the same refference: {0}", ReferenceEquals(ivanStudent, cloneIvan)); Console.WriteLine(ReferenceEquals(ivanStudent, ivanStudent)); }
static void Main() { Name petio = new Name("Peter", "Petrov", "Petranov"); Address petioHome = new Address("Kaspichan", "Vasil Levski", 5); Student petioTheStudent = new Student(petio, "123-45-7890", petioHome, "088-777-666", "*****@*****.**", 3, Specialties.CSharpProgrammer, Universities.TelerikAcademy, Faculties.Second); Console.WriteLine(petioTheStudent); Console.WriteLine(petioTheStudent.GetHashCode()); Student copyOfPetio = (Student)petioTheStudent.Clone(); Console.WriteLine(object.ReferenceEquals(petioTheStudent.Name.FirstName, copyOfPetio.Name.FirstName)); Console.WriteLine(object.ReferenceEquals(petioTheStudent.SSN, copyOfPetio.SSN)); Console.WriteLine(petioTheStudent.CompareTo(copyOfPetio)); }
static void Main() { Student student1 = new Student("Pesho", "Pehsev", "Peshev", 12345, "Sofia", 89765223, "*****@*****.**", University.SU, Faculty.finance, Specialty.finance); Student student2 = new Student("Pesho", "Peshev", "Peshev", 54331, "Sofia", 7432487, "*****@*****.**", University.TU, Faculty.IT, Specialty.IT); Console.WriteLine(student1); Console.WriteLine(); Console.WriteLine(student2); Console.WriteLine(student1 != student2); Console.WriteLine(student1 == student2); Console.WriteLine(student1.GetHashCode()); Console.WriteLine(); Student student3 = (Student)student1.Clone(); Console.WriteLine(student3); Console.WriteLine(student1.ComparerTo(student2)); Console.WriteLine(student1.ComparerTo(student3)); }
private void InputStudent_Load(object sender, EventArgs e) { ComboBox_Groups.Items.Clear(); Button_Next.Enabled = !m_ChangeFlag; ComboBox_Groups.Enabled = !m_ChangeFlag; this.ActiveControl = TextBox_Surname; // Add mode if (!m_ChangeFlag) { m_Student = (Student)m_WorkStudent.Clone(); m_IsModify = true; this.Text = "Input Student Information"; this.AcceptButton = Button_Next; } // Change mode if (m_ChangeFlag) { TextBox_Surname.Text = m_Student.surname; TextBox_Name.Text = m_Student.name; TextBox_Lastname.Text = m_Student.lastname; TextBox_Birth_Year.Text = m_Student.birthYear.ToString(); TextBox_Average_Mark.Text = m_Student.mark.ToString(); m_WorkStudent = m_Student; m_IsModify = false; this.Text = "Change Student Information"; this.AcceptButton = Button_OK; } setActiveSurname(); if (!Object.ReferenceEquals(m_Faculty, null)) { var currentGroup = m_Faculty.currentData; int counter = 0; foreach (var curElem in m_Faculty.chooseOrder(true)) { ComboBox_Groups.Items.Insert(counter++, curElem.nameList); } ComboBox_Groups.SelectedIndex = m_CurrentGroupIndex != -1 ? m_CurrentGroupIndex : 0; } }