static void Main() { ConsoleApp.ClrScr(); IdentifyApplication(); OpenFiles(); employeeList1.Fill(fileIn); employeeList1.SelectionSort(Employee.CompareIDs); employeeList1.AppendReport(fileOut, "All Employees in List One - ID Order"); employeeList1.SelectionSort(Employee.CompareNames); employeeList1.AppendReport(fileOut, "All Employees in List One - Name Order"); employeeList1.SelectionSort(Employee.CompareHireDates); employeeList1.AppendReport(fileOut, "All Employees in List One - Hire Date Order"); employeeList1.SelectionSort(Employee.CompareEarnings); employeeList1.AppendReport(fileOut, "All Employees in List One - Earnings Order"); employeeList1.SelectionSort(Employee.CompareTypes); employeeList1.AppendReport(fileOut, "All Employees in List One - Type Order"); foreach (Employee employee in employeeList1) if (employee is Supervisor) employeeSublist.Add(((Supervisor) employee).Clone()); employeeSublist.AppendReport(fileOut, "Supervisor Employees in List One - Name Order"); employeeSublist.Clear(); foreach (Employee employee in employeeList1) if (employee is Hourly) employeeSublist.Add(employee); employeeSublist.AppendReport(fileOut, "Hourly Employees in List One - Name Order"); employeeSublist.Clear(); foreach (Employee employee in employeeList1) if (employee is Commission) employeeSublist.Add(employee); employeeSublist.AppendReport(fileOut, "Commission Employees in List One - Name Order"); employeeSublist.Clear(); foreach (Employee employee in employeeList1) if (employee is Piece) employeeSublist.Add(employee); employeeSublist.AppendReport(fileOut, "Piece Employees in List One - Name Order"); employeeList1.SelectionSort(Employee.CompareNames); //employeeList1.SelectionSort(EmployeeList.OrderEnum.NameOrder); employee1 = new Supervisor(employeeList1.AssignID(), "Lawson, LeAnn", "Jun 15, 1989", 1500.00); index = ~employeeList1.BinarySearch(employee1, Employee.CompareNames); //index = ~employeeList1.BinarySearch(employee1, EmployeeList.OrderEnum.NameOrder); employeeList1.InsertAt(index, employee1); employeeList1.AppendReport(fileOut, "All Employees in List One - Name Order"); employeeList2 = employeeList1.Clone(); employeeList2.RemoveAt(index); employeeList2.AppendReport(fileOut, "All Employees in List Two - Name Order"); CloseFiles(); }
// Copy constructor public EmployeeList(EmployeeList sourceList) { this.Copy(sourceList); }
public void Copy(EmployeeList sourceList) { this.Clear(); foreach (Employee employee in sourceList) this.Add(employee.Clone()); }
private void IncreaseCapacity() { EmployeeList tempList; tempList = new EmployeeList(2 * this.capacity); foreach (Employee employee in this) tempList.Add(employee); this.capacity = tempList.capacity; this.count = tempList.count; this.items = tempList.items; }