https://github.com/jonathas/injury-recovery-calculator
Calculate the exact date and time a player will be able to play again
https://github.com/jonathas/injury-recovery-calculator
football game php phpunit
Last synced: 2 months ago
JSON representation
Calculate the exact date and time a player will be able to play again
- Host: GitHub
- URL: https://github.com/jonathas/injury-recovery-calculator
- Owner: jonathas
- License: gpl-2.0
- Created: 2015-05-10T15:07:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-12T15:14:08.000Z (almost 10 years ago)
- Last Synced: 2025-01-16T22:37:30.190Z (4 months ago)
- Topics: football, game, php, phpunit
- Language: PHP
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Injury recovery calculator
==========================[](https://travis-ci.org/jonathas/injury-recovery-calculator)
A football player needs t hours to recover from an injury. For a full recovery, he needs to receive t hours of special treatment from the team’s doctor. A user can submit new injuries to the application, which then calculates the exact date and time the player will be able to play again.
The rules
---------- The doctor works from 10AM to 4PM.
- The doctor only works on regular working days (Monday to Friday). For simplicity's sake, you should not deal with holidays, so only weekends are considered off days.
- The needed recovery time is always provided in hours. It tells how many hours of treatment is needed until the player can be considered recovered.
- A treatment can only be started during the doctor’s working hours.
- If the doctor is out of office at the time of submission, he will start the treatment at the beginning of the next working day.
For instance, if a treatment starts at 11:04AM on Thursday and it takes 10 hours to finish the treatment, the recovery date will be 03:04PM on Friday.
The task
---------Implement the calculateRecoveryDate method. It takes the start time and the hours of treatment needed, and returns the date and time of full recovery.
Try to avoid using a library that is not part of the language.
A unit tested solution is preferred.
Instructions
------------Install the dependencies: composer install
Run the tests: php vendor/bin/phpunit tests
Ways to run the project:
1) php injury-recovery-calculator.php '10:00 am' 10
2) php -S localhost:8080