public static void Main(string[] args) { int id = 0; int id2 = 1; int id3 = 2; List <Dictionary <int, string> > studentList = new List <Dictionary <int, string> >(); Dictionary <int, string> dict = new Dictionary <int, string>(); dict.Add(id, "Mary"); studentList.Add(dict); Student st = new Student("Mary", id); Student st2 = new Student("Josiah", id2); Student st3 = new Student("Ben", id3); Student st4 = st; st.Gpa = 4.0; st3.NumberOfCredits = 18; st2.Gpa = 3.98; Console.WriteLine(st3.Name + " " + st3.NumberOfCredits); Course c0 = new Course(10, "CodeCamp", false, 14, "Ben Clark"); Course c1 = new Course(12, "LC101"); List <Student> roster = new List <Student>() { st, st2, st3 }; c0.ClassRoster = roster; Console.WriteLine(c0.NumCredits); Console.WriteLine(c1.NumCredits + c1.Name + c1.RequiresPrereq); foreach (Student stu in c0.ClassRoster) { Console.WriteLine(stu.Name); } st.AddGrade(4, 4.0); st.AddGrade(3, 4.0); st.AddGrade(3, 4.0); Console.WriteLine($"Student: {st.Name}. GPA: {st.Gpa}"); Console.WriteLine("Student ToString: " + st.ToString()); Console.WriteLine($"Student ToString: {st}"); Console.WriteLine($"1. {st.Equals(c1)}"); Console.WriteLine($"2. {st.Equals(st4)}"); Console.WriteLine("3. " + st.Equals(new Student("Mary", 0))); Console.WriteLine(st.GetHashCode() + " " + st2.GetHashCode()); Console.WriteLine(new Student("Mary", 0).GetHashCode()); }
static void Main(string[] args) { Student Taemin = new Student("Taemin"); Student Onew = new Student("Onew"); List <Student> students = new List <Student>() { Taemin }; Course SHINee = new Course("SHINee", "Lee Soo Man", students); SHINee.AddStudent(Onew); Console.WriteLine(SHINee.Name); Console.WriteLine(SHINee.Professor); Taemin.AddGrade(5, 100); Taemin.AddGrade(5, 90); Console.WriteLine(Taemin.GetGradeLevel()); //Console.WriteLine(Taemin.Gpa); //set to private Console.WriteLine(Taemin); //Taemin (Credits: 10, GPA: 95) Onew.AddGrade(3, 80); Console.WriteLine(SHINee); Console.WriteLine(Taemin.Equals(Taemin)); Console.WriteLine(Taemin.Equals(Onew)); }
public static void Main(string[] args) { Student st = new Student("Alysson", 0); Student st2 = new Student("Dan", 1); Student st3 = new Student("Mila", 2); st.Gpa = 2.0; st3.NumberOfCredits = 18; Console.WriteLine(st3.StudentId); Console.WriteLine(st3.Name + " " + st3.StudentId); Course c1 = new Course(101, "CodeCamp", false, 14, "Ben Clark"); Course c2 = new Course(201, "LiftOff"); List <Student> roster = new List <Student>() { st2, st3 }; c1.ClassRoster = roster; //foreach(Student stu in c1.ClassRoster) //{ // Console.WriteLine(stu.Name); //} //Console.WriteLine("Requires Prerequisite? " + c1.RequiresPrereq); //Console.WriteLine(c2.Name + " " + c2.CourseId); st.AddGrade(4, 4.0); st2.AddGrade(4, 3.7); st3.AddGrade(3, 3.5); Student st4 = st; Console.WriteLine(st.Name + ":" + st2.Gpa); Console.WriteLine(st2.GetGradeLevel()); Console.WriteLine("Student ToString " + st); Console.WriteLine("Student ToString " + st.ToString()); Console.WriteLine("1 " + st.Equals(st2)); Console.WriteLine("2 " + st.Equals(st4)); Console.WriteLine("3 " + st.Equals(new Student("Alysson", 0))); Console.WriteLine(st.GetHashCode() + " " + st2.GetHashCode()); Console.WriteLine(new Student("Alysson", 0).GetHashCode()); }
public static void Main(string[] args) { Student student1 = new Student("Nancy", 0); Student student2 = new Student("Samuel", 1); Student student3 = new Student("Lois", 2); Student student4 = student1; Course c1 = new Course(10, "CodeCamp", false, 14, "Ben"); Course c2 = new Course(451, "LC101"); Console.WriteLine("Name:" + c1.Name + "; CourseID:" + c1.CourseId); List <Student> roster = new List <Student>() { student1, student2 }; c1.ClassRoster = roster; Console.WriteLine("Credits per year:" + Student.GetCreditPerYear()); student1.AddGrade(10, 3.0); student1.AddGrade(8, 4.0); student1.AddGrade(6, 2.5); Console.WriteLine("Student:" + student1.Name + ";" + " GPA: " + student1.Gpa); Console.WriteLine("Student level: " + student1.GetGradeLevel()); Console.WriteLine("Student ToString: " + student1.ToString()); Console.WriteLine("Student ToString: " + student1); Console.WriteLine("1 " + student1.Equals(student2)); Console.WriteLine("2 " + student1.Equals(student4)); Console.WriteLine("3 " + student1.Equals(new Student("Nancy", 0))); foreach (Student stu in c1.ClassRoster) { Console.WriteLine(stu.Name); } /*student1.Gpa = 3.9; * student3.NumberOfCredits = 18; * * Console.WriteLine("{0} {1} {2}", student1.Gpa, student2.Name, student3.NumberOfCredits);*/ }
static void Main(string[] args) { Student vivian = new Student("Vivi"); Student student1 = new Student("Student 1", 4); Student student2 = new Student("Student 2", 4); student2.AddGrade(3, 4); student2.AddGrade(3, 3); Console.WriteLine(vivian); Console.WriteLine(student1); Console.WriteLine(student2); // SEE EQUAL() SPECIAL METHOD AND ITS OVERRIDE IN THE STUDENT CLASS if (student1.Equals(student2)) { Console.WriteLine("Student 1's ID# " + student1.GetStudentID() + " is the same as student 2's ID# " + student2.GetStudentID() + "."); } else { Console.WriteLine("Student 1's ID# " + student1.GetStudentID() + " is not the same as student 2's ID# " + student2.GetStudentID() + "."); } Console.ReadLine(); }
public static void Main(string[] args) { Student st = new Student("Ben", 0); Student st2 = new Student("Audrey", 1); Student st3 = new Student("Wade", 3); Student st4 = st; st.Gpa = 2.0; st3.NumberOfCredits = 18; Console.WriteLine(st.Name + " " + st.StudentId); Course c1; Course c2; c1 = new Course(10, "CodeCamp ", false, 14, "Ben"); c2 = new Course(101, "LC101"); Console.WriteLine("Name: " + c1.Name + "Credits: " + c1.NumCredits); //st.studentId = "55"; Console.WriteLine(st.Name + " " + st.StudentId); List <Student> roster = new List <Student>() { st2, st3 }; c1.ClassRoster = roster; st.AddGrade(10, 3.0); st.AddGrade(8, 4.0); st.AddGrade(6, 3.0); Console.WriteLine("Student: " + st.Name + " GPA: " + st.Gpa); Console.WriteLine("Student Level: " + st.GetGradeLevel()); Console.WriteLine("Student ToString: " + st.ToString()); Console.WriteLine("Student ToString: " + st); Console.WriteLine("1 " + st.Equals(st2)); Console.WriteLine("2 " + st.Equals(st4)); Console.WriteLine("3 " + st.Equals(new Student("Ben", 0))); Console.WriteLine(st.GetHashCode() + " " + st2.GetHashCode()); Console.WriteLine(new Student("Ben", 0).GetHashCode()); }
public void TestStudentClone() { Student student = new Student("Nikolay Kostadinov", 10000); Student cloneStudent = (Student)student.Clone(); Assert.AreEqual(student.GetHashCode() == cloneStudent.GetHashCode(), false, "Invalid DeepCopy"); Assert.AreEqual(student.Equals(cloneStudent), false, "Invalid DeepCopy"); Assert.AreEqual(student.Name, cloneStudent.Name, "Invalid DeepCopy"); Assert.AreEqual(student.Id, cloneStudent.Id, "Invalid DeepCopy"); }
public void StudentCloneTest() { Student studentOne = new Student(); studentOne.FirstName = "Ivan"; studentOne.MiddleName = "Petrov"; studentOne.LastName = "Ivanov"; studentOne.Address = "Dolno Uino"; studentOne.Course = "C# OOP"; Student studentOneClone = (Student)studentOne.Clone(); Assert.IsTrue(studentOne.Equals(studentOneClone)); }
public static void Main(string[] args) { Student st = new Student("Ben", 0); Student st2 = new Student("Audrey", 1); Student st3 = new Student("Wade", 2); Student st4 = st; Course c1 = new Course(10, "CodeCamp", false, 14, "Ben"); Course c2 = new Course(101, "LC101"); Console.WriteLine("Name: " + c1.Name + " Credits: " + c1.NumCredits); List <Student> roster = new List <Student>() { st2, st3 }; c1.ClassRoster = roster; Console.WriteLine("Credits per year: " + Student.GetCreditsPerYear()); st.AddGrade(10, 3.0); st.AddGrade(8, 4.0); st.AddGrade(6, 2.5); Console.WriteLine("Student: " + st.Name + " GPA: " + st.Gpa); Console.WriteLine("Student Level: " + st.GetGradeLevel()); Console.WriteLine("Student ToString: " + st.ToString()); Console.WriteLine("Student ToString: " + st); Console.WriteLine("1 " + st.Equals(st2)); Console.WriteLine("2 " + st.Equals(st4)); Console.WriteLine("3 " + st.Equals(new Student("Ben", 0))); }