I am doing a Java ME project which acquires input such as current location and destination from the use and then display the appropriate information such as bus service to take, travel time and image of the bus stop.
So here the problem...
There are three bus services for each location.
Location 1: 95, 100, 14
Location 1: 20, 14, 144 where 20 95 100 and 14 are the bus number.
i have retrieved the bus services from mysql.
they are stored as String types
cbus1,cbus2,cbu s3 (services for current location) and
dbus1, dbus2, dbus3 (services for destination).
I need to run through them get the services that are present in both the current location and destination.
I have initialized three variables common1, common2, common3 to 0.
I need to store the value of the common services in these three variables.
After they are stored I will use a very simple but long if else statement to combine them as a variable and send to the midlet.
How do cycle through the bus numbers and get the common ones?
So here the problem...
There are three bus services for each location.
Location 1: 95, 100, 14
Location 1: 20, 14, 144 where 20 95 100 and 14 are the bus number.
i have retrieved the bus services from mysql.
they are stored as String types
cbus1,cbus2,cbu s3 (services for current location) and
dbus1, dbus2, dbus3 (services for destination).
I need to run through them get the services that are present in both the current location and destination.
I have initialized three variables common1, common2, common3 to 0.
I need to store the value of the common services in these three variables.
After they are stored I will use a very simple but long if else statement to combine them as a variable and send to the midlet.
Code:
if (common1==0&&common2==0 &&common3==0){ String bussvc = "No Services available"; } else if (common2==0 &&common3==0){ String bussvc = Integer.toString(common1); } else if (common1==0 && common3==0){ String bussvc = Integer.toString(common2); } else if (common1==0 && common2==0){ String bussvc = Integer.toString(common3); } else if (common1==0 && common2==0){ String bussvc = Integer.toString(common3); } else if (common3==0){ String bussvc = ""+Integer.toString(common1)+"+","+"+Integer.toString(common1)+"" } . . . . .
Comment