-
Notifications
You must be signed in to change notification settings - Fork 1.5k
new check #1602
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?
new check #1602
Changes from 6 commits
42293a7
18cfc27
4424661
f4f3059
9f6ff82
000e8f5
aab8e59
f1f8839
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,37 @@ | ||||||
| package core.basesyntax; | ||||||
|
|
||||||
| import java.time.LocalDate; | ||||||
| import java.time.format.DateTimeFormatter; | ||||||
|
|
||||||
|
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. Remove this empty line - checklist item #1 prohibits empty lines at the beginning of class implementation. |
||||||
| public class SalaryInfo { | ||||||
|
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. Variable names such as |
||||||
| private static final 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.
Suggested change
|
||||||
| private static final String REPORT = "Report for period "; | ||||||
|
|
||||||
|
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. Remove this empty line - checklist item #1 prohibits empty lines at the beginning of method implementation. |
||||||
| public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) { | ||||||
| return null; | ||||||
| LocalDate from = LocalDate.parse(dateFrom, formatter); | ||||||
| LocalDate to = LocalDate.parse(dateTo, formatter); | ||||||
|
|
||||||
| StringBuilder report = new StringBuilder(); | ||||||
| report.append(REPORT).append(dateFrom).append(" - ").append(dateTo).append(System.lineSeparator()); | ||||||
|
|
||||||
| for (String name : names) { | ||||||
| int salary = 0; | ||||||
|
|
||||||
| for (String datum : data) { | ||||||
| String[] dataArray = datum.split(" "); | ||||||
| LocalDate localDate = LocalDate.parse(dataArray[0], formatter); | ||||||
| if (!localDate.isBefore(from) | ||||||
| && !localDate.isAfter(to) | ||||||
| && name.equals(dataArray[1])) { | ||||||
| salary += Integer.parseInt(dataArray[2]) | ||||||
| * Integer.parseInt(dataArray[3]); | ||||||
| } | ||||||
|
Comment on lines
+22
to
+29
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. Consider extracting the indexes from |
||||||
| } | ||||||
| report.append(name).append(" - ").append(salary); | ||||||
| if (!name.equals(names[names.length - 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. Avoid checking whether the current employee is the last one using: This can give incorrect formatting if the |
||||||
| report.append(System.lineSeparator()); | ||||||
| } | ||||||
| } | ||||||
| return report.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.
Remove this empty line - checklist item #1 prohibits empty lines at the beginning of class implementation.