I am building one taxi app and it is working god but I have one question with the fare calculator.
I have setup so the customer can see when then they before booking trip they can see how much it will cost but here is the problem if they book one long trip the cost will be expensive but if they book one trip that is under 10km the cost is fine. so I wonder can you calculator different fare cost. if the trip is more than 10 km is should calculator different price and so on like 20km different fare ....?
if yes you can do it, how do you do it? here down is my code.
public String getDurationString(){
int days = (int) duration / 86400;
int hours = ((int) duration - days * 86400) / 3600;
int minutes = ((int) duration - days * 86400 - hours * 3600) / 60;
int seconds = (int) duration - days * 86400 - hours * 3600 - minutes * 60;
return hours + " hour " + minutes + "min";
}
and the calculator fare
public static int rideCostEstimate(double distance, double duration, int people){
double price;
price = 36 + distance * 26 + duration * 0.001;
if(people == 1){
price = 36 + distance * 26 + duration * 0.001;
}else if(people == 2){
price = 42 + distance * 32 + duration * 0.005;
}
return (int) price;
}
on the calculator that say (people == 1) and (people == 2) is that if the customer want a normal car or big car. just like uber, like uberX or uberSUV.