/// <summary> /// Moves an Executive out of the current department, into a new department /// </summary> /// <param name="executive"></param> /// <param name="department"></param> public void Change(Executive executive, Department department) { //remove executive from current department this.Quit(executive); //add exectuvie to target department department.Join(executive); }
/// <summary> /// Display all executives in a queue, given a listview container. /// </summary> /// <param name="executives"></param> /// <param name="listView"></param> private void ListExecutives(Department department, ListView listView) { //clear the list to prevent scrolling duplicates listView.Clear(); //use enumeration to add items from the queue to the list Queue<Executive>.Enumerator enumerator = department.Executives.GetEnumerator(); while (enumerator.MoveNext()) { listView.Items.Add(enumerator.Current.ToString()); } }
/// <summary> /// The Init method loads the form with sample data. /// </summary> private void Init() { //instantiate new departments Department zero = new Department("UMKC", Guid.NewGuid()); Department one = new Department("Students", Guid.NewGuid()); Department two = new Department("Workers", Guid.NewGuid()); //add executives to departments zero.Join(new Executive("Mohammad", "Kuhail", Guid.NewGuid())); zero.Join(new Executive("Hussam", "Hashem", Guid.NewGuid())); zero.Join(new Executive("James", "Clark", Guid.NewGuid())); one.Join(new Executive("Kim", "Heckman", Guid.NewGuid())); one.Join(new Executive("Rebecca", "Clark", Guid.NewGuid())); two.Join(new Executive("Patrick", "Connelly", Guid.NewGuid())); two.Join(new Executive("Justin", "Noonan", Guid.NewGuid())); //put the departments in an array, per program requirements departments[0] = zero; departments[1] = one; departments[2] = two; //list executives in listview containers ListExecutives(zero, lvDepartment1); ListExecutives(one, lvDepartment2); ListExecutives(two, lvDepartment3); }