Detention Time Calculator.

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 –

  1. 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.

  1. Good Time.

If the student is first time offender, s/he is given a 10% reduction in her/his detention period.

  1. 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

Stealing                                                          2

Fighting                                                          .5

Untidyness                                                     1

Lying                                                            1.5

SchoolPropertyDamage                              1

  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).

Notes:

  1. The solution should be extensible. (New offense types, changes in detention periods for existing detention periods, new rules for detention, etc).
  2. AutomatedTests would be seen as an Added advantage. Automated test for #4 will be “extra” added advantage.
  3. Design simple UI, preferably a web interface using MVC, using AJAX.
  4. 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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s