I have a jobArray array with 5 jobs that contain a description, hours needed to complete, and an hourly pay that a user enters.
I need to sort the array when it prints by ascending order of the total fee (hours * hourly pay).
The assignment requires I use the IComparable interface when doing so but I'm unsure how to use it. Any help would be appreciated, thank you
Here is my job class
class Job : IComparable
{
public Job(string description, int hours, double hourRate, double fee)
{
Description = description;
hoursToComplete = hoursToComplete;
hourlyRate = hourlyRate;
totalFee = totalFee;
}
This is the interface I've done to compare totalFees
public int CompareTo(Job o)
{
int returnVal;
Job temp = (Job)o;
if (this.totalFee > temp.totalFee)
returnVal = 1;
else
if (this.totalFee < temp.totalFee)
returnVal = -1;
else
returnVal = 0;
return returnVal;
}
I'm unsure what do to from here as to sorting the jobs when they print out by total fees.