-
Notifications
You must be signed in to change notification settings - Fork 1.5k
first commit #1592
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?
first commit #1592
Changes from 2 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,42 @@ | ||
| 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; | ||
|
|
||
| StringBuilder result = new StringBuilder("Report for period " + dateFrom + " - " + dateTo | ||
| + "\n"); | ||
|
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. Checklist #7 violation: Use |
||
| 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. Checklist #2 violation: DateTimeFormatter should be a constant field (private static final), not a local variable. Move it outside the method. |
||
| LocalDate from = LocalDate.parse(dateFrom, formatter); | ||
| LocalDate to = LocalDate.parse(dateTo, formatter); | ||
|
|
||
| for (String name : names) { | ||
| int totalSalary = 0; | ||
|
|
||
| for (String records : data) { | ||
|
Comment on lines
+19
to
+20
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. Two empty lines before the inner loop are redundant. Remove extra empty lines per checklist #1. |
||
| String[] dataParts = records.split(" "); | ||
| LocalDate currentDate = LocalDate.parse(dataParts[0], formatter); | ||
| String currentName = dataParts[1]; | ||
| int currentHours = Integer.parseInt(dataParts[2]); | ||
| int currentRate = Integer.parseInt(dataParts[3]); | ||
| int salary = currentHours * currentRate; | ||
|
|
||
| if (name.equals(currentName) | ||
| && !currentDate.isBefore(from) | ||
| && !currentDate.isAfter(to)) { | ||
| totalSalary += salary; | ||
| } | ||
|
|
||
| } | ||
|
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. Empty line inside the if block is redundant. Remove per checklist #1. |
||
| result.append(name) | ||
| .append(" - ") | ||
| .append(totalSalary) | ||
| .append("\n"); | ||
| } | ||
|
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. Checklist #7 violation: Use |
||
| result.deleteCharAt(result.length() - 1); | ||
| return result.toString(); | ||
| } | ||
|
|
||
| } | ||
|
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. Empty line before class closing brace is redundant. Remove per checklist #1. |
||
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.
Empty lines at the start of method implementation violate checklist #1. Remove this empty line.