mardi 11 août 2015

Which design pattern can be used for the Railway ticket fare calculation?

I am developing a solution which is similar to railway ticketing.

Context : 18 Railway Stations from Tamil Nadu are given. A passenger needs a ticket. For upto 5 stations journey, the fare is Rs.10. After the 5 stations, for every 5 stations, 5 Rs extra will be charged. For the full stretch journey i.e. From 1st to the last station, fare is Rs. 20.

e.g.

Input 1 : StationFrom - Guindy, StationTo - Kadambakkam
Output 1 : Print ticket. i.e. StationFrom : Guindy, StationTo : Kadambakkam, Total Stops : 3, Total Fare : 10

Input 2 : StationFrom - Guindy , StationTo - Chennai Fort
Output 2 : Print ticket. i.e. StationFrom : Guindy, StationTo : Chennai Fort, Total Stops : 8, Total Fare :15

In future, more business rules on fare calculation can be added.

The question is, which design patterns would be correct choice in the fare calculation?

Aucun commentaire:

Enregistrer un commentaire