-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add files via upload #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add files via upload #1481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,45 @@ | ||
| package core.basesyntax; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.format.DateTimeFormatter; | ||
|
|
||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "If a date formatter is created, it must be a constant field." The formatter should be declared as a static final constant, not inside the method. |
||
| LocalDate startDate = LocalDate.parse(dateFrom, formatter); | ||
| LocalDate endDate = LocalDate.parse(dateTo, formatter); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| StringBuilder reportBuilder = new StringBuilder(); | ||
| reportBuilder.append("Report for period ") | ||
| .append(dateFrom) | ||
| .append(" - ") | ||
| .append(dateTo); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| for (String name : names) { | ||
| int totalSalary = 0; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| for (String record : data) { | ||
| String[] parts = record.split(" "); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants. |
||
| String recordDateStr = parts[0]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants. |
||
| String recordName = parts[1]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants. |
||
| int hours = Integer.parseInt(parts[2]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants. |
||
| int rate = Integer.parseInt(parts[3]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants. |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| LocalDate recordDate = LocalDate.parse(recordDateStr, formatter); | ||
|
|
||
| if (name.equals(recordName) | ||
| && !recordDate.isBefore(startDate) | ||
| && !recordDate.isAfter(endDate)) { | ||
| totalSalary += hours * rate; | ||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| reportBuilder.append(System.lineSeparator()) | ||
| .append(name) | ||
| .append(" - ") | ||
| .append(totalSalary); | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code." |
||
| return reportBuilder.toString(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."