Skip to content

Instantly share code, notes, and snippets.

@horsdal
Created March 13, 2013 21:20
Show Gist options
  • Save horsdal/5156392 to your computer and use it in GitHub Desktop.
Save horsdal/5156392 to your computer and use it in GitHub Desktop.
public class Course
{
private readonly List<Registrant> registrants = new List<Registrant>();
public CourseTemplate Template { get; private set; }
public bool IsMorning { get; private set; }
public IEnumerable<Registrant> Registrants { get { return registrants; } }
public bool IsFull { get { return Template.Limit < registrants.Count; } }
public bool IsEmpty { get { return registrants.Count == 0; } }
public Course(CourseTemplate template, bool isMorning)
{
IsMorning = isMorning;
Template = template;
}
public void Register(Registrant registrant)
{
if (!registrants.Contains(registrant))
registrants.Add(registrant);
}
public void Start()
{
// ... allocate instructor and run the course ...
}
public void AwardDiplomas()
{
// ... award diplomas to all registrants who passed
}
public override bool Equals(object obj)
{
var other = obj as Course;
if (other == null)
return false;
return Equals(registrants, other.registrants) && Equals(Template, other.Template) && IsMorning.Equals(other.IsMorning);
}
// some hashcode implementation ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment