Created
March 13, 2013 21:20
-
-
Save horsdal/5156392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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