public static void Main() { Student st = new Student("Black", University.UASG); var st1 = new Student("John", "Smith",11234,"World","09841233","*****@*****.**", 4, University.SofiaUniversity, Specialty.SoftwareDevelopment,Faculty.Informatics); Console.WriteLine(st.Equals(st1)); Console.WriteLine(st1.ToString()); if (st1 == st) { Console.WriteLine("Equal"); } else { Console.WriteLine("False"); } }
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 }
/* 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); }
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); }
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); }
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()); }
private void BtnCreate_Click(object sender, EventArgs e) { Student student = new Student(TxtFirstName.Text, TxtLastName.Text, int.Parse(TxtAge.Text)); LbxStudents.Items.Add(student.ToString()); }