Johnny has been a bad boy. He has committed several offenses and played a lot of pranks at school. He has been caught and now Mr. Wilson, the school head master has to give him detention. The period of detention depends on several factors as per rules of the school board and poor Mr. Wilson needs some help.
So we would like you to write a detention calculator which takes a student having a list of offenses and gives the detention to be awarded based on the below rules to help Mr. Wilson –
- Detention can be consecutive or concurrent.
‘Concurrent’ detention is for cases when the student is being detained for more than one offense at the same time. This is the default detention type when an offense is added to a student.
‘Consecutive’ detention is for cases when a student will be detained for one charge before beginning to serve time for the second one, third one, etc. In most cases, the Starting DateTime of the second charge will be equal to the Ending DateTime of the previous charge. However it could be next day too in some cases.
Detention calculator should be able to compute detention in both modes.
- Good Time.
If the student is first time offender, s/he is given a 10% reduction in her/his detention period.
- Bad Time
If the student is repeat offender, s/he is given 10% increase in her/his detention period.
Following are standard offense types –
OffenseTypes Detention Period (in hours)
Homework Not Done 1
- A student cannot be detained for more than a school day (8 hours) without parent’s consent. If such a case arises, his/her parents have to be called. Detention calculator should throw an exception in such a scenario which could be used by the calling application to take appropriate action (show a message for example).
- The solution should be extensible. (New offense types, changes in detention periods for existing detention periods, new rules for detention, etc).
- AutomatedTests would be seen as an Added advantage. Automated test for #4 will be “extra” added advantage.
- Design simple UI, preferably a web interface using MVC, using AJAX.
- User should be able to enter user name and select one or more offense types along with options to choose Good Time/Bad Time & calculation mode (Concurrent/Consecutive). There should be a calculate button, which should calculate the detention based on input and provide result.