public static void Run() { char y = 'n'; do { var student = new Student(); System.Console.Write("Enter Your Id: "); student.Id = Convert.ToInt32(System.Console.ReadLine()); System.Console.Write("Enter Your Name: "); student.Name = System.Console.ReadLine(); StudentRowGateway gateway = new StudentRowGateway(student); gateway.InsertStudent(); System.Console.Write("Do you want to add More (y)"); y = System.Console.ReadLine()[0]; } while (y == 'y'); var students = StudentFinder.GetAll(); foreach (var student in students) { System.Console.WriteLine($" Student {student.Id} Name is {student.Name} "); } System.Console.ReadLine(); }
static void Main(string[] args) { var st1 = new Student("Lola", "0906353637", Department.Sociology); var st2 = new Student("Winnie", "0906353633", Department.Agriculture); var st3 = new Student("Muna", "0906353635", Department.BusinessAdmin); var st4 = new Student("Hassan", "0906353638", Department.Biology); Student[] students = { st1, st2, st3, st4 }; //var results = OldStudentFinder.FindStudentByName(students, "Muna"); //foreach(var s in results) //{ // Console.WriteLine($"We found {s.Name}"); //} //results = OldStudentFinder.FindStudentByDepartment(students, Department.Sociology); //foreach (var s in results) //{ // Console.WriteLine($"We found {s.Name} with department {s.department}"); //} /////////////////////////////////////////////////////////////////////////// var sf = new StudentFinder(); foreach (var s in sf.Finder(students, new DepartmentFindBy(Department.BusinessAdmin))) { Console.WriteLine($"The student with name: {s.Name} and department {s.department} was found"); } foreach (var s in sf.Finder(students, new NameFindBy("Lola"))) { Console.WriteLine($"The student with name: {s.Name} and department {s.department} was found"); } Console.ReadLine(); }