Java
Java copied to clipboard
Add edge case to handle negative rod length in RodCutting algorithm
- [x] I have read CONTRIBUTING.md.
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
- [x] All new code is formatted with
clang-format -i --style=file path/to/your/file.java
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 66.88%. Comparing base (
69a1424) to head (7478547).
Additional details and impacted files
@@ Coverage Diff @@
## master #5904 +/- ##
=========================================
Coverage 66.88% 66.88%
- Complexity 4516 4517 +1
=========================================
Files 613 613
Lines 16994 16996 +2
Branches 3281 3282 +1
=========================================
+ Hits 11366 11368 +2
Misses 5181 5181
Partials 447 447
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I’ve made some updates to the RodCutting algorithm to handle an edge case where the length of the rod is negative. Previously, the code didn’t account for this situation, which could lead to unexpected behavior.
Now, I’ve added an IllegalArgumentException to ensure that if a negative rod length is passed, it throws a clear error message, preventing any further calculations. This change should enhance the robustness of the algorithm.
Additionally, I've implemented a test case for this scenario, and it’s working correctly to validate the expected behavior.