fix throw not exists paths
This commit is contained in:
@@ -39,6 +39,8 @@ public class TransitPath {
|
||||
} else {
|
||||
fuel = refill(edges, entries.size()-1);
|
||||
}
|
||||
if (fuel < 0)
|
||||
throw new IllegalStateException("Is not exists path");
|
||||
refillCount++;
|
||||
} else {
|
||||
fuel -= fuelCost;
|
||||
@@ -62,14 +64,14 @@ public class TransitPath {
|
||||
}
|
||||
double remain = max != -1 ? Math.min(max, e.getRefill()) : e.getRefill();
|
||||
double fuelCost = e.getFuelCost(remain);
|
||||
double fuel = updateFuelCost(edges, i+1, startIndex, remain-fuelCost);
|
||||
if (fuel < 0){
|
||||
continue;
|
||||
}
|
||||
this.fuelCost += fuelCost - ce.getFuelCost();
|
||||
ce.setFuelCost(fuelCost);
|
||||
ce.setRefill(remain);
|
||||
remain = updateFuelCost(edges, i+1, startIndex, remain-fuelCost);
|
||||
if (remain < 0){
|
||||
continue;
|
||||
}
|
||||
return remain;
|
||||
return fuel;
|
||||
}
|
||||
if (max == -1 || e.getMaxFuel() < max){
|
||||
max = e.getMaxFuel();
|
||||
|
||||
@@ -186,6 +186,10 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
||||
break;
|
||||
}
|
||||
path = path.add(cEdge);
|
||||
if (path.getMinFuel() > path.getMaxFuel()){
|
||||
LOG.trace("Path inaccessible");
|
||||
break;
|
||||
}
|
||||
if (!source.equals(target)){
|
||||
addEdge(source, target, path);
|
||||
}
|
||||
@@ -235,6 +239,10 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
||||
break;
|
||||
}
|
||||
path = path.add(cEdge);
|
||||
if (path.getMinFuel() > path.getMaxFuel()){
|
||||
LOG.trace("Path inaccessible");
|
||||
break;
|
||||
}
|
||||
if (!source.equals(target)){
|
||||
addEdge(source, target, path);
|
||||
}
|
||||
@@ -430,7 +438,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
||||
int jumps = source.getEntry().getPlace().equals(target.getEntry().getPlace())? 0 : 1;
|
||||
int lands = 1; double fuel = fuelCost;
|
||||
if (path != null){
|
||||
jumps = path.size(); fuel = getFuelCost();
|
||||
jumps = path.size()-1; fuel = getFuelCost();
|
||||
lands += path.getRefillCount();
|
||||
}
|
||||
double profit = getProfit();
|
||||
|
||||
Reference in New Issue
Block a user