-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added logic to 'getSalaryInfo' method #1077
base: master
Are you sure you want to change the base?
Added logic to 'getSalaryInfo' method #1077
Conversation
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.
Great job, but there are some points to consider
.append(dateFrom).append(" - ") | ||
.append(dateTo); | ||
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d.MM.yyyy"); |
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.
It is recommended to make your formatter a constant field
&& workDay.isAfter(startDate) | ||
&& (workDay.isEqual(endDate) | ||
|| workDay.isBefore(endDate))) { |
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.
I believe we can simplify this if statement by only checking on !isBefore
and !isAfter
, what do you think?
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.
Just one minor point to consider
.append(dateFrom).append(" - ") | ||
.append(dateTo); | ||
|
||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d.MM.yyyy"); |
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.
Please, make your formatter a constant (private
static
final
and class level)
public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) { | ||
return null; | ||
String paragraph = System.lineSeparator(); | ||
StringBuilder builder = new StringBuilder("Report for period ") |
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.
I recommend you be more specific in this case because the builder name is too generic
if (name.equals(employeeInfo[1]) | ||
&& !workDay.isAfter(endDate) | ||
&& !workDay.isBefore(startDate)) { | ||
totalSalary += Integer.parseInt(employeeInfo[2]) | ||
* Integer.parseInt(employeeInfo[3]); | ||
} | ||
} |
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.
It's hard to understand what is stored under arrayName[someIndex] without knowing the input format, it's always better to extract such expressions in separate variables with proper names to give some context on what is actually going on
No description provided.