C#学习小记9包装类以封装预定义类集群

using System;
using System.Collections;
public class Student
{
   public string a="89";
}
public class EnrollmentCollection
{
   private ArrayList students;
   public EnrollmentCollection()
   {
   students=new ArrayList();
    }
   public void Enroll(Student s)
    {
     students.Add(s);
    }

}
public class Course
{
private EnrollmentCollection enrolledStudents;
public Course()
   {
    enrolledStudents=new EnrollmentCollection();
   }
public void Enroll(Student s)
{
    enrolledStudents.Enroll(s);
}
}
public class Do
{ static void Main()
{
Course a=new Course();
Student b=new Student();
Student c=new Student();
Student d=new Student();
   a.Enroll(b);a.Enroll(c);a.Enroll(d);
}
}

posted on 2008-08-06 13:27  yatasoft  阅读(269)  评论(0编辑  收藏  举报

导航