-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fixed method' #1353
base: master
Are you sure you want to change the base?
fixed method' #1353
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 on the implementation! While using StringBuilder can enhance performance in certain scenarios, your current approach is perfectly fine here. Keep up the good work and continue exploring ways to optimize your code! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
StringBuilder salaryInfo = new StringBuilder("Report for period " | ||
+ dateFrom + " - " + dateTo); |
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.
Consider using StringBuilder for concatenating strings within the loop to improve performance. However, in this case, since it's outside of the loop, it's acceptable to use simple concatenation.
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.
Good job! Please check comments
private static final DateTimeFormatter DATE_FORMATTER = | ||
DateTimeFormatter.ofPattern("dd.MM.yyyy"); | ||
private static final int DAY_POSITION = 0; | ||
private static final int NAME = 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.
private static final int NAME = 1; | |
private static final int NAME_INDEX = 1; |
DateTimeFormatter.ofPattern("dd.MM.yyyy"); | ||
private static final int DAY_POSITION = 0; | ||
private static final int NAME = 1; | ||
private static final int HOUR = 2; |
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.
private static final int HOUR = 2; | |
private static final int HOUR_INDEX = 2; |
for (String name : names) { | ||
int salary = 0; | ||
for (String info: data) { | ||
String[] infoSplit = info.split(" "); |
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.
String[] infoSplit = info.split(" "); | |
String[] infoSplit = info.split(SPACE); |
salary += hours * salaryHour; | ||
} | ||
} | ||
salaryInfo.append(System.lineSeparator()).append(name).append(" - ").append(salary); |
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.
salaryInfo.append(System.lineSeparator()).append(name).append(" - ").append(salary); | |
salaryInfo.append(System.lineSeparator()).append(name).append(DASH).append(salary); |
private static final int NAME = 1; | ||
private static final int HOUR = 2; | ||
private static final int SALARY_PER_HOUR = 3; | ||
|
||
public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) { |
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.
This method is very complicated, please break it down into several methods, for example: createReport, calculateSallaryInfo
No description provided.