Question: For this assignment we are going to continue to work on some fundamental skills as we learn about more complex structures. For this assignment there
For this assignment we are going to continue to work on some fundamental skills as we learn about more complex structures. For this assignment there is a class called Record. It contains details for each employee of a company.
You're assignment is to write the code for the compare function for this class. This compare function has a small twist. There are two arguments, the first is an enum tag telling the function which field to use for comparison, the second is the compared Record. As noted in the header file, the function returns an int. The return value of zero indicates that the two objects are the same based on the field requested. Positive return values mean the compared object is lesser (or sequentially before), negative mean the compared object is greater(or sequentially after).
The test code included with this lab will sort a set of Records based on your compare function. The sort is already written (sortBy). When you are running in develop mode enter the field you would like to sort by. If the output does not show that the field are sorted based on the field you requested - there is a bug in your compare function that you will want to fix. You will be tested on all fields, so you should check them all before running in submit mode. You may submit more than once.
#include
using namespace std;
void printRecords(vector
void sortBy(Record::fieldType sortField, vector HOW THE OUT PUT SHOULD LOOK: Unsorted Name: Bowie, David, years in service:5, grade: 8, last review: Improvement Plan Name: Kardashian, Kim, years in service:15, grade: 9, last review: Meets Expectations Name: Kardashian, Khloe, years in service:5, grade: 10, last review: Outstanding Name: Lee Roth, David, years in service:9, grade: 4, last review: Below Expectations Name: Garbo, Greta, years in service:1, grade: 3, last review: Outstanding enter a field (0-4) to sort by: Sorted Name: Bowie, David, years in service:5, grade: 8, last review: Improvement Plan Name: Lee Roth, David, years in service:9, grade: 4, last review: Below Expectations Name: Garbo, Greta, years in service:1, grade: 3, last review: Outstanding Name: Kardashian, Khloe, years in service:5, grade: 10, last review: Outstanding Name: Kardashian, Kim, years in service:15, grade: 9, last review: Meets Expectations
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
