Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/Palina.java
Show All 15 Lines | BusTO (backend components) | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.backend; | package it.reyboz.bustorino.backend; | ||||
import android.util.Log; | import android.util.Log; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Calendar; | import java.util.Calendar; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
* Timetable for multiple routes.<br> | * Timetable for multiple routes.<br> | ||||
Show All 10 Lines | public Palina(String stopID) { | ||||
super(stopID); | super(stopID); | ||||
} | } | ||||
public Palina(Stop s){ | public Palina(Stop s){ | ||||
super(s.ID,s.getStopDefaultName(),s.getStopUserName(),s.location,s.type, | super(s.ID,s.getStopDefaultName(),s.getStopUserName(),s.location,s.type, | ||||
s.getRoutesThatStopHere(),s.getLatitude(),s.getLongitude()); | s.getRoutesThatStopHere(),s.getLatitude(),s.getLongitude()); | ||||
} | } | ||||
public Palina(@NonNull String ID, @Nullable String name, @Nullable String userName, | |||||
@Nullable String location, | |||||
@Nullable Double lat, @Nullable Double lon) { | |||||
super(ID, name, userName, location, null, null, lat, lon); | |||||
} | |||||
public Palina(@Nullable String name, @NonNull String ID, @Nullable String location, @Nullable Route.Type type, @Nullable List<String> routesThatStopHere) { | |||||
super(name, ID, location, type, routesThatStopHere); | |||||
} | |||||
/** | /** | ||||
* Adds a timetable entry to a route. | * Adds a timetable entry to a route. | ||||
* | * | ||||
* @param TimeGTT time in GTT format (e.g. "11:22*") | * @param TimeGTT time in GTT format (e.g. "11:22*") | ||||
* @param arrayIndex position in the array for this route (returned by addRoute) | * @param arrayIndex position in the array for this route (returned by addRoute) | ||||
*/ | */ | ||||
public void addPassaggio(String TimeGTT, Passaggio.Source src,int arrayIndex) { | public void addPassaggio(String TimeGTT, Passaggio.Source src,int arrayIndex) { | ||||
▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | public void mergeDuplicateRoutes(int startidx){ | ||||
r.mergeRouteWithAnother(routeCheck); | r.mergeRouteWithAnother(routeCheck); | ||||
found=true; | found=true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (found) mergeDuplicateRoutes(startidx); | if (found) mergeDuplicateRoutes(startidx); | ||||
else mergeDuplicateRoutes(startidx+1); | else mergeDuplicateRoutes(startidx+1); | ||||
} | } | ||||
public int getTotalNumberOfPassages(){ | |||||
int tot = 0; | |||||
if(routes==null) | |||||
return tot; | |||||
for(Route r: routes){ | |||||
tot += r.numPassaggi(); | |||||
} | |||||
return tot; | |||||
} | |||||
public int getMinNumberOfPassages(){ | |||||
if (routes == null) return 0; | |||||
int min = Integer.MAX_VALUE; | |||||
if( routes.size() == 0) min = 0; | |||||
else for (Route r : routes){ | |||||
min = Math.min(min,r.numPassaggi()); | |||||
} | |||||
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