Implement salary info calculation - #1598
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation correctly fulfills all functional requirements. The date range filtering, parsing logic, and output formatting work as expected using appropriate Java 8+ APIs. While there are two checklist violations regarding constants (DateTimeFormatter should be a class-level constant per item #2, and the regex pattern and array indices should be named constants per item #9), these are code style improvements rather than functional blockers since the code produces correct results. The core logic is sound and the implementation passes the required functionality tests.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| public class SalaryInfo { | ||
| public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) { | ||
| return null; | ||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); |
There was a problem hiding this comment.
This violates checklist item #2: 'If you create a formatter, make it a constant field'. Move the DateTimeFormatter to be a private static final constant at the class level.
| int totalSalary = 0; | ||
|
|
||
| for (String record : data) { | ||
| String[] parts = record.split("\\s+"); |
There was a problem hiding this comment.
This violates checklist item #9: 'Any magic numbers should be constants'. The regex pattern "\\s+" should be defined as a constant with an informative name (e.g., DATA_ENTRY_SPLITTER).
| int hours = Integer.parseInt(parts[2]); | ||
| int salaryPerHour = Integer.parseInt(parts[3]); |
There was a problem hiding this comment.
This violates checklist item #9: 'Any magic numbers should be constants'. Array indices 2 (hours) and 3 (salary per hour) should be defined as named constants for better readability.
No description provided.