Monday 13 July 2015

Coding Interview Question on Metro Smart Card System


Click HERE to see the complete interview process at sapient

Problem Statement :
Our Company has been asked to implement Metro Smart Card System (MSCS) for Delhi City. For this application assume there is a single metro line covering 10 stations linearly.

The stations name are A1,A2,A3,A4,A5,A6,A7,...A10. The travel can be in any direction from any station except A1 and A10.

Travelers have smart card that behave just like any other regular debit card that has an initial balance when purchased. Travelers swipe in when they enter a metro station and swipe out when they exit. Card balance is automatically updated at swipe out.

Objective :

Objective of this exercise is to create an automated system that has following functionality.

Card should have a minimum balance of Rs. 50 at swipe-in. At swipe-out, system should calculate the fare based on below strategies. The fare must be deducted from the card. Card should have the sufficient balance otherwise user should not be able to exit.

Weekday - Rs 7 * (Number of stations travelled)
Weekend - Rs 5.5 * (Number of station traveled if it is Saturday or Sunday )
(* there could be more such fare strategies in future).

Additionally system needs to have functionality to generate some statistics/report defined below. So system needs to provide following API.


  • API to get total foot-fall(swipe-in + swipe-out) for a given station.
  • API to generate a "per-card report" on demand. It should print the following information on console.
      Card<number> used to travel from <source_station> to station <destination_station>. Fare is Rs<x> and balance on card is Rs<x>.

CLICK Code Sample   to download the sample code for this problem.
Above code sample is created by using command line design pattern which is appropriate for this problem. However this is just for reference and you could practice this problem to find more appropriate solution.
 

36 comments:

  1. Thanks for the code details.
    However, I am unable to download the sample code. Below error is coming while clicking on the Code Sample link.

    CONFIDENTIAL
    This document contains sensitive information

    Please help.

    ReplyDelete
    Replies
    1. Request you to change the browser and try again. Its downloading without any issue or send me your mail address, I will send you the code.

      Delete
    2. This comment has been removed by the author.

      Delete
  2. Hi Mayank,

    I am also not able to download the code if possible kindly send me code on this email address prashantlko2009@gmail.com

    ReplyDelete
  3. Hi,

    I have mailed you the code.

    ReplyDelete
  4. Hi Mayank,
    Nice article, really helpful.
    Even I am not able to download the code if possible kindly send me the code on this email address salmanhauqec1063@gmail.com

    ReplyDelete
  5. Hi Mayank,

    Not able to download in chrome,firefox and IE. if it is possible to send this on my email id -surendrapandey3788@gmail.com

    ReplyDelete
  6. hello sir,
    project file is not able to open if it is possible by mail, humble request you to mail at chetangupta664@gmail.com.

    ReplyDelete
  7. please mail me now if possible .. I have my interview tomorrow

    ReplyDelete
  8. Replies
    1. Can you please mail me also
      Aishaishlaxmi.ar@gmail.com

      Delete
  9. I am also not able to download.Could you please mail me at kankariyaabhi@gmail.com

    ReplyDelete
    Replies
    1. Hi,did you get the code.I am able to download it properly. If you need, I can mail you.

      Delete
    2. Please mail me as well, tanveer.jss@gmail.com.

      Thanks.

      Delete
  10. please mail me the code too,
    rajesh.aneja3049@gmail.com

    ReplyDelete
  11. Hi,
    Can anyone please let me know what sort of usecase are they giving in the Coding Round to implement for Apache Spark Developer.

    ReplyDelete
  12. I am unable to download the file in chrome please mail me the code : pramod4it@gmail.com

    ReplyDelete
  13. If you face any issues in downloading code, please try with different browser.

    ReplyDelete
  14. Hi There,

    I have made an attempt to download your code but it shows message

    'We're sorry, this file type is not currently supported.' , somehow I have downloaded the source file and have imported the same into eclipse.
    After import I am getting problem with the 'Helper.api' package section(especially the class 'TravelDetailsJDBCTemplate'),code in the same class is highlighted with red color.




    ReplyDelete
  15. Please provide me the code at vivek.charak@gmail.com as am not able to download from the link.

    Thanks

    ReplyDelete
  16. please help me with the code at aakritiagarwal009@gmail.com

    ReplyDelete
  17. Please provide me the code at kuldeep.choudhary144@gmail.com as am not able to download from the link.

    ReplyDelete
  18. Please provide me the code at umme77520@gmail.com as ism not able to download it i have an interview tomorrow

    ReplyDelete
  19. hi, pls send this on my id daksh2801@gmail.com. also, can you tell which codind software do they use for coding test? Thanks!

    ReplyDelete
  20. Please provide me the code for this arpitguptahcst9@gmail.com

    ReplyDelete
  21. Please provide the code on ketangupta05@gmail.com

    ReplyDelete
  22. Please mail me as well at monica8727@gmail.com

    ReplyDelete
  23. please mail me as well at shaleenjain999@gmail.com

    ReplyDelete
  24. hi Can you please provide me the code , i need it today .
    Email : rohit.ntil@gmail.com

    ReplyDelete
  25. please mail me as well at udayrai1512@gmail.com
    Its not opening in browser..tried lot of times

    ReplyDelete
  26. are they provide internet connectivity or not to complete the assignment.

    ReplyDelete