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);
}
}

转载于:https://www.cnblogs.com/yatasoft/archive/2008/08/06/1261940.html

你可能感兴趣的:(C#学习小记9包装类以封装预定义类集群)