choongzhanhong / transport-tool

A tool to help with public transport in Singapore.
0 stars 1 forks source link

Fare Distance Calculator #2

Open choongzhanhong opened 11 months ago

choongzhanhong commented 11 months ago

Should be simple enough, right?

Tashuuuu commented 11 months ago

I would like to work on it. Could you please describe it more?

choongzhanhong commented 11 months ago

I would like to work on it. Could you please describe it more?

Hi friend. Thank you for your comment! In particular, Singapore's bus and train fares are based on distance, there are some tables at the bottom of this page.

There are different prices for Adult, Child, Senior, and so on. I believe there are repetitions in the table too, Bus and DTL/NEL/LRT (Train) fares are identical.

I have not yet determined if there is a formula or pattern, but I believe it can (and should) be hard-coded as a series of if-elseif blocks.

The fares will be increased on 23 December 2023. So, it would be easier to change the code when time comes.

If you are working on this, could you begin with the adult bus fare calculator as a javascript function that takes in parameter distance in meters? (Distance is calculated in kilometers but to avoid float inaccuracy we can convert to integer)