I have a franchise class with owner(owner of franchise\'s name), state(2-character string for the state where the franchise is located), and sales (total sales for the day)<
You have to modify your compareTo
method. Cause you are returning after comparing the state. So you have to compare state but sales too.
For example:
public int compareTo(Franchise that) {
int stateComparition = this.getState().compareTo(that.getState());
Double sales = Double.valueOf(this.getSales());
Double thatSales = Double.valueOf(that.getSales());
int salesComparition = sales.compareTo(thatSales);
if(stateComparition == 0){
if(salesComparition > 0)
return -1;
else if(salesComparition < 0)
return 1;
else
return 0;
}
return stateComparition;
}