Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fixed method' #1353

wants to merge 2 commits into from

Conversation

LizaBalshv
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! ✨

Comment on lines 17 to 18
StringBuilder salaryInfo = new StringBuilder("Report for period "
+ dateFrom + " - " + dateTo);

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.

Copy link

@ahoienko ahoienko left a 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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(" ");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String[] infoSplit = info.split(" ");
String[] infoSplit = info.split(SPACE);

salary += hours * salaryHour;
}
}
salaryInfo.append(System.lineSeparator()).append(name).append(" - ").append(salary);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants