I am given an assignment to sort an array of inputted values using both insertion sort and selection sort. I am having some trouble with overwriting the compareTo method with in the Item class. I would like it to sort so that if two items are priced the same it then compares based on Category. So Child (C) items come first and then M and then Women. This is my code and every time that I attempt to compile it I get an error saying that double cannot be referenced.
public int compareTo (Object other) {
int result;
double otherPrice = ((Item)other).getClothPrice();
String otherCategory = ((Item)other).getClothCategory();
if (clothPrice == otherPrice)
result = clothCategory.compareTo(otherCategory);
else
result = clothPrice.compareTo(otherPrice);
return result;
}