|
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace FinderTest
{
class Program
{
static void Main(string[] args)
{
Class c1 = new Class("0603", "jsp", Semesters.x1);
Student s1 = new Student(1, "zs", Genders.male, DateTime.Parse("1988-02-23"), "13088522635");
Student s2 = new Student(2, "ls", Genders.female, DateTime.Parse("1986-12-03"), "13188522888");
Student s3 = new Student(3, "ww", Genders.female, DateTime.Parse("1988-11-15"), "13288576885");
Student s4 = new Student(4, "zl", Genders.male, DateTime.Parse("1984-02-21"), "13388534635");
Student s5 = new Student(5, "qq", Genders.female, DateTime.Parse("1988-02-23"), "13488524335");
Student s6 = new Student(6, "cb", Genders.male, DateTime.Parse("1989-02-23"), "13588527636");
c1.AllStudents.Add(s1);
c1.AllStudents.Add(s2);
c1.AllStudents.Add(s3);
c1.AllStudents.Add(s4);
c1.AllStudents.Add(s5);
c1.AllStudents.Add(s6);
ArrayList list= c1.FindAll(match);
//尋找班級女生的資料
// ArrayList list = c1.FindAll(match1);
//尋找學號從1到5的學生
foreach (Student s in list)
{
s.show();
}
}
//條件為女性
public static bool match(Student s)
{
if (s.Gender.Equals(Genders.female))
{
return true;
}
return false;
}
//條件為學號從1到5
public static bool match1(Student s)
{
if (s.Id.CompareTo(1) >= 0 && s.Id.CompareTo(5) <= 0)
{
return true;
}
return false;
}
}
}
|