Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/Palina.java
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | public int getTotalNumberOfPassages(){ | ||||
int tot = 0; | int tot = 0; | ||||
if(routes==null) | if(routes==null) | ||||
return tot; | return tot; | ||||
for(Route r: routes){ | for(Route r: routes){ | ||||
tot += r.numPassaggi(); | tot += r.numPassaggi(); | ||||
} | } | ||||
return tot; | return tot; | ||||
} | } | ||||
/** | |||||
* Compute the minimum number of passages per route | |||||
* Ignoring empty routes | |||||
* @return the minimum, or 0 if there are no passages/routes | |||||
*/ | |||||
public int getMinNumberOfPassages(){ | public int getMinNumberOfPassages(){ | ||||
if (routes == null) return 0; | if (routes == null) return 0; | ||||
int min = Integer.MAX_VALUE; | int min = Integer.MAX_VALUE; | ||||
if( routes.size() == 0) min = 0; | if( routes.size() == 0) min = 0; | ||||
else for (Route r : routes){ | else for (Route r : routes){ | ||||
if(r.numPassaggi()>0) | |||||
min = Math.min(min,r.numPassaggi()); | min = Math.min(min,r.numPassaggi()); | ||||
} | } | ||||
return min; | if (min == Integer.MAX_VALUE) return 0; | ||||
else return min; | |||||
} | } | ||||
//private void mergeRoute | //private void mergeRoute | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register