Skip to content

ramit21/MetroCodingProblem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

MetroCodingProblem

Coding exercise on Metro

Duration: 3 hrs

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 used to travel from <source_station> to station <destination_station>. Fare is Rs and balance on card is Rs.

Tips: Use design patterns (Singleton for services, Builder for datamodels etc) Write JUnits. No static void main. Enums for constants (eg. days of the week) Data models should be very specific to their use. Make custom exceptions for boundary situations (Write junit for these too) Services implement interfaces, and based on singleton patterns. Controllers are the exposed APIs.

About

Coding exercise on Metro

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages