Exemple #1
0
int main(int argc, char** argv) {

    tm hiringYear;
    hiringYear.tm_year=2000;
	vector<CEmployee*> emps;
    CManager mang("Tom","Cruise",40000, hiringYear, "Sales", emps);
    CManager mang1("Alice","Cooper",45000, hiringYear, "Human Resources", emps);

    //Add records to database
	/*
    vector<CEmployee*> allEmp;
    CDatabase emp_data(allEmp);
    hiringYear.tm_year=2011;
    emp_data.AddRecord(new CEmployee("\nJohn","Smith1",10000,hiringYear));
    hiringYear.tm_year=2012;
    emp_data.AddRecord(new CEmployee("\nJohn","Smith2",20000,hiringYear));
    hiringYear.tm_year=2013;
    emp_data.AddRecord(new CEmployee("\nJohn","Smith2",30000,hiringYear));
    hiringYear.tm_year=2000;
    emp_data.AddRecord(new CManager("\nTom","Cruise",40000,hiringYear, "Sales"));
    hiringYear.tm_year=2010;
    emp_data.AddRecord(new CEmployee("\nJohn","Doe1",15000,hiringYear));
    hiringYear.tm_year=2011;
    emp_data.AddRecord(new CEmployee("\nJohn","Doe2",25000,hiringYear));
    hiringYear.tm_year=2012;
    emp_data.AddRecord(new CEmployee("\nJohn","Doe3",35000,hiringYear));
    hiringYear.tm_year=2000;
    emp_data.AddRecord(new CManager("\nAlice","Cooper",45000,hiringYear, "Human Resources"));
	*/
	vector<CEmployee*> allEmp;
	hiringYear.tm_year = 2011;
	allEmp.push_back(new CEmployee("\nJohn", "Smith1", 10000, hiringYear));
	hiringYear.tm_year = 2012;
	allEmp.push_back(new CEmployee("\nMike", "Smith2", 20000, hiringYear));
	hiringYear.tm_year = 2013;
	allEmp.push_back(new CEmployee("\nSam", "Smith3", 30000, hiringYear));
	hiringYear.tm_year = 2000;
	allEmp.push_back(new CManager("\nTom", "Cruise", 40000, hiringYear, "Sales", emps));
	hiringYear.tm_year = 2010;
	allEmp.push_back(new CEmployee("\nBob", "Doe1", 15000, hiringYear));
	hiringYear.tm_year = 2011;
	allEmp.push_back(new CEmployee("\nBill", "Doe2", 25000, hiringYear));
	hiringYear.tm_year = 2012;
	allEmp.push_back(new CEmployee("\nFrank", "Doe3", 35000, hiringYear));
	hiringYear.tm_year = 2000;
	allEmp.push_back(new CManager("\nAlice", "Cooper", 45000, hiringYear, "Human Resources", emps));
	CDatabase emp_data(allEmp);
    //display all records
	cout << "*********************************Unsorted*******************************************\n" << endl;
    emp_data.DisplayRecords();
	
    BubbleSortIncreasing bsInc;
	BubbleSortDecreasing bsDec;
    EmployeeDatabaseSortByFirstName svSortedByFirstName(allEmp);
	cout << "\n\n***************************Sort By First Name Inc*******************************\n" << endl;
    bsInc.sort(&svSortedByFirstName);
	svSortedByFirstName.DisplayRecords();
	cout << "\n\n***************************Sort By First Name Dec*******************************\n" << endl;
    bsDec.sort(&svSortedByFirstName);
	svSortedByFirstName.DisplayRecords();
    
	
    EmployeeDatabaseSortByLastName svSortedByLastName(allEmp);
	cout << "\n\n***************************Sort By Last Name Inc*******************************\n" << endl;
    bsInc.sort(&svSortedByLastName);
	svSortedByLastName.DisplayRecords();
	cout << "\n\n***************************Sort By Last Name Dec*******************************\n" << endl;
    bsDec.sort(&svSortedByLastName);
	svSortedByLastName.DisplayRecords();

	
    EmployeeDatabaseSortBySalary svSortedBySalary(allEmp);
	cout << "\n\n***************************Sort By Salary Inc*******************************\n" << endl;
    bsInc.sort(&svSortedBySalary);
	svSortedBySalary.DisplayRecords();
	cout << "\n\n***************************Sort By Salary Dec*******************************\n" << endl;
    bsDec.sort(&svSortedBySalary);
	svSortedBySalary.DisplayRecords();
    
	
    EmployeeDatabaseSortByHireYear svSortedByHireYear(allEmp);
	cout << "\n\n***************************Sort By Hire Year Inc*******************************\n" << endl;
    bsInc.sort(&svSortedByHireYear);
	svSortedByHireYear.DisplayRecords();
	cout << "\n\n***************************Sort By Hire Year Dec*******************************\n" << endl;
    bsDec.sort(&svSortedByHireYear);
	svSortedByHireYear.DisplayRecords();

	cout << "\n****************************************************************************" << endl;

    
    return 0;
}
Exemple #2
0
int main(int argc, char** argv) {
    tm HiringYear; 
    CEmployee JohnSmith1("John","Smith1",10000,2011);
    CEmployee JohnSmith2("John","Smith2",20000,2012);
    CEmployee JohnSmith3("John","Smith3",30000,2013);
    
    vector<CEmployee*> Employees;
    Employees.push_back(&JohnSmith1);
    Employees.push_back(&JohnSmith2);
    Employees.push_back(&JohnSmith3);
    
    CManager TomCruiseManager("Tom","Cruise",40000,2000,"Sales",Employees);
    Employees.push_back(&TomCruiseManager);
    
   
    CEmployee JohnDoe1("John","Doe1",15000,2010);
    CEmployee JohnDoe2("John","Doe2",25000,2011);
    CEmployee JohnDoe3("John","Doe3",35000,2012);
    
    Employees.push_back(&JohnDoe1);
    Employees.push_back(&JohnDoe2);
    Employees.push_back(&JohnDoe3);
    
    vector<CEmployee*> HREmployees;
    HREmployees.push_back(&JohnDoe1);
    HREmployees.push_back(&JohnDoe2);
    HREmployees.push_back(&JohnDoe3);
    
    CManager AliceCooperManager("Alice","Cooper",45000,2000,"Human Resources",HREmployees);
    Employees.push_back(&AliceCooperManager);
    
    CDatabase database(Employees);
 cout<<"***************** Before Sorting"<<endl;
 database.DisplayRecords();
 BubbleSortIncreasing bsIncreasing;
 BubbleSortDecreasing bsDecreasing;
 
 cout<<"***************** After Sorting By FirstName Alphabetical"<<endl;
 EmployeeVectorSortByFirstName evSortedByFirstName(Employees);
 bsIncreasing.sort(&evSortedByFirstName);
 evSortedByFirstName.DisplayRecords();
 
 cout<<"***************** After Sorting By FirstName Reverse Alphabetical"<<endl;
 bsDecreasing.sort(&evSortedByFirstName);
 evSortedByFirstName.DisplayRecords();
 
 cout<<"***************** After Sorting By LastName Alphabetical"<<endl;
 EmployeeVectorSortByLastName evSortedByLastName(Employees);
 bsIncreasing.sort(&evSortedByLastName);
 evSortedByLastName.DisplayRecords();
 
 cout<<"***************** After Sorting By LastName Reverse Alphabetical"<<endl;
 bsDecreasing.sort(&evSortedByLastName);
 evSortedByLastName.DisplayRecords();
 
 cout<<"***************** After Sorting By Salary Increasing"<<endl;
 EmployeeVectorSortBySalary evsortedbysalary(Employees);
 bsIncreasing.sort(&evsortedbysalary);
 evsortedbysalary.DisplayRecords();
 
 cout<<"***************** After Sorting By Salary Decreasing"<<endl;
 bsDecreasing.sort(&evsortedbysalary);
 evsortedbysalary.DisplayRecords();
 
 
 cout<<"***************** After Sorting By Hire year Increasing"<<endl;
 EmployeeVectorSortByHiringYear evsortedbyhireyear(Employees);
 bsIncreasing.sort(&evsortedbyhireyear);
 evsortedbyhireyear.DisplayRecords();
 
 cout<<"***************** After Sorting By Hire year Decreasing"<<endl;
 bsDecreasing.sort(&evsortedbyhireyear);
 evsortedbyhireyear.DisplayRecords();
 
 
    return 0;
}
int main(int argc, char** argv) {
   
    tm hiringYear;
    vector<CEmployee*> allEmps;
    
    vector<CEmployee*>emps1, emps2;
    emps1.push_back(new CEmployee("John", "Smith", 10000, hiringYear));
    emps2.push_back(new CEmployee("John", "Doe", 15000, hiringYear));
    
    
    //build vector of employee and managers
    hiringYear.tm_year = 2011;
    allEmps.push_back(new CEmployee("John", "Smith1", 10000, hiringYear));
    hiringYear.tm_year = 2012;
    allEmps.push_back(new CEmployee("John", "Smith2", 20000, hiringYear));
    hiringYear.tm_year = 2013;
    allEmps.push_back(new CEmployee("John", "Smith3", 30000, hiringYear));
    hiringYear.tm_year = 2000;
    allEmps.push_back(new CManager("Tom", "Cruise", 40000, hiringYear,"Sales", emps1));
    
   
    
    hiringYear.tm_year = 2010;
    allEmps.push_back(new CEmployee("John", "Doe1", 15000, hiringYear));
    hiringYear.tm_year = 2011;
    allEmps.push_back(new CEmployee("John", "Doe2", 25000, hiringYear));
    hiringYear.tm_year = 2012;
    allEmps.push_back(new CEmployee("John", "Doe3", 35000, hiringYear));
    hiringYear.tm_year = 2000;
    allEmps.push_back(new CManager("Alice", "Cooper", 45000, hiringYear,"Human Resources", emps2));
    
    
       
    BubbleSortIncreasing bsInc;
    BubbleSortDecreasing bsDec;
    
    cout<<"*****************************Before Sorting"<<endl;
    CDatabase DBbeforeSort(allEmps);
    DBbeforeSort.print();

    cout<<"*****************************After Sorting by FirstName Alphabetical"<<endl;
    CDatabaseSortByFirstName DBSortedByFirstName(allEmps);
    bsInc.sort(&DBSortedByFirstName);
    DBSortedByFirstName.print();
    
    cout<<"*****************************After Sorting by FirstName Reverse Alphabetical"<<endl;
    CDatabaseSortByFirstName DBSortedByFirstNameReverse(allEmps);
    bsDec.sort(&DBSortedByFirstNameReverse);
    DBSortedByFirstNameReverse.print();
  
    cout<<"*****************************After Sorting by Last Name Alphabetical"<<endl;
    CDatabaseSortByLastName DBSortedByLastName(allEmps);
    bsInc.sort(&DBSortedByLastName);
    DBSortedByLastName.print();
    
    cout<<"*****************************After Sorting by Last Name Reverse Alphabetical"<<endl;
    CDatabaseSortByLastName DBSortedByLastNameReverse(allEmps);
    bsDec.sort(&DBSortedByLastNameReverse);
    DBSortedByLastNameReverse.print();
    
    cout<<"*****************************After Sorting by Salary Increasing"<<endl;
    CDatabaseSortBySalary DBSortedBySalary(allEmps);
    bsInc.sort(&DBSortedBySalary);
    DBSortedBySalary.print();
    
    cout<<"*****************************After Sorting by Salary Decreasing"<<endl;
    CDatabaseSortBySalary DBSortedBySalaryDec(allEmps);
    bsDec.sort(&DBSortedBySalaryDec);
    DBSortedBySalaryDec.print();
    
    cout<<"*****************************After Sorting by HiringYear Increasing"<<endl;
    CDatabaseSortByHiringYear DBSortedByHiringYear(allEmps);
    bsInc.sort(&DBSortedByHiringYear);
    DBSortedByHiringYear.print();
    
    cout<<"*****************************After Sorting by HiringYear Decreasing"<<endl;
    CDatabaseSortByHiringYear DBSortedByHiringYearDec(allEmps);
    bsDec.sort(&DBSortedByHiringYearDec);
    DBSortedByHiringYearDec.print();
  
  
    
    return 0;
}