Datasheet
6
x
CHAPTER 1 PRIMER
{
get { return m_major; }
set { m_major = value; }
}
}
class Instructor : Person
{
private string m_dept;
public Instructor(string fn, string ln, int a, string dept)
: base(fn, ln, a)
{
Department = dept;
}
public string Department
{
get { return m_dept; }
set { m_dept = value; }
}
}
class Class
{
private string m_name;
private List<Student> m_students = new List<Student>();
private Instructor m_instructor;
public Class(string n)
{
Name = n;
}
public string Name
{
get { return m_name; }
set { m_name = value; }
}
public Instructor Instructor
{
get { return m_instructor; }
set { m_instructor = value; }
}
public List<Student> Students
{
get { return m_students; }
}
}
As with most systems of its type, the system begins simply: there are two kinds of “Person”s in the
system,
Students and Instructors, and Classes are taught to Students by Instructors. So,
building up from basic parts, lists of
Instructors and Students might look like this:
class Program
{
static List<Student> Students = new List<Student>();
static List<Instructor> Instructors = new List<Instructor>();
c01.indd 6c01.indd 6 10/1/2010 3:20:36 PM10/1/2010 3:20:36 PM