Java icon indicating copy to clipboard operation
Java copied to clipboard

Add `LotteryScheduling` new algorithm with Junit tests

Open Hardvan opened this issue 1 year ago • 5 comments

  • [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

Hardvan avatar Oct 09 '24 05:10 Hardvan

Codecov Report

Attention: Patch coverage is 74.46809% with 12 lines in your changes missing coverage. Please review.

Project coverage is 64.25%. Comparing base (213fd5a) to head (343035b).

Files with missing lines Patch % Lines
...om/thealgorithms/scheduling/LotteryScheduling.java 74.46% 9 Missing and 3 partials :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5656      +/-   ##
============================================
+ Coverage     64.21%   64.25%   +0.03%     
- Complexity     4216     4221       +5     
============================================
  Files           588      589       +1     
  Lines         16426    16473      +47     
  Branches       3170     3174       +4     
============================================
+ Hits          10548    10584      +36     
- Misses         5448     5457       +9     
- Partials        430      432       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 09 '24 05:10 codecov-commenter

Please fix infer PR check

siriak avatar Oct 10 '24 17:10 siriak

I think the infer check is failing because I added a new dependency (mockito) in the pom.xml file. Mockito is needed for mocking the random number generator in the test cases.

Hardvan avatar Oct 10 '24 17:10 Hardvan

It says src/main/java/com/thealgorithms/scheduling/LotteryScheduling.java:56: error: Null Dereference(NULLPTR_DEREFERENCE) selectedProcess could be null (from the call to LotteryScheduling.selectProcessByTicket(...) on line 54) and is dereferenced. 54. Process selectedProcess = selectProcessByTicket(winningTicket); 55.
56. > selectedProcess.setWaitingTime(currentTime); 57. currentTime += selectedProcess.getBurstTime(); 58. selectedProcess.setTurnAroundTime(selectedProcess.getWaitingTime() + selectedProcess.getBurstTime());

siriak avatar Oct 12 '24 07:10 siriak

I have fixed the bug.

Hardvan avatar Oct 13 '24 03:10 Hardvan