Archived
0

implement equals for route

This commit is contained in:
iMoHax
2015-06-23 17:57:31 +03:00
parent 48fa67a7fa
commit 940ad274ad
2 changed files with 28 additions and 1 deletions

View File

@@ -120,7 +120,7 @@ public class Route {
if (this == o) return true;
if (!(o instanceof Route)) return false;
Route route = (Route) o;
return entries.equals(route.entries);
return Double.compare(route.profit, profit) == 0 && entries.equals(route.entries);
}
@Override

View File

@@ -83,6 +83,33 @@ public class RouteEntry {
return !isLand();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RouteEntry)) return false;
RouteEntry that = (RouteEntry) o;
if (land != that.land) return false;
if (refill != that.refill) return false;
if (Double.compare(that.fuel, fuel) != 0) return false;
if (orders.size() != that.orders.size()) return false;
return vendor.equals(that.vendor);
}
@Override
public int hashCode() {
int result;
long temp;
result = vendor.hashCode();
temp = Double.doubleToLongBits(fuel);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (land ? 1 : 0);
result = 31 * result + (refill ? 1 : 0);
temp = Double.doubleToLongBits(score);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public String toString() {
return vendor + (isRefill() ? " (R)":"");