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

getSalaryInfo method was implemented #1259

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

Conversation

NadVlados
Copy link

No description provided.

Comment on lines 15 to 21
LocalDate date;
String nameOfEmployee;
int hours;
int salaryPerHour;
int compareToDateFrom;
int compareToDateTo;
String[] personInformation;

Choose a reason for hiding this comment

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

declare it inline

Suggested change
LocalDate date;
String nameOfEmployee;
int hours;
int salaryPerHour;
int compareToDateFrom;
int compareToDateTo;
String[] personInformation;

Comment on lines 31 to 32
compareToDateFrom = localDateFrom.compareTo(date);
compareToDateTo = localDateTo.compareTo(date);

Choose a reason for hiding this comment

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

just use isBefore and isAfter, it will improve your code readability

finalSalary[List.of(names).indexOf(nameOfEmployee)] += hours * salaryPerHour;
}
}
return dataToString(names,finalSalary,dateFrom,dateTo);

Choose a reason for hiding this comment

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

Suggested change
return dataToString(names,finalSalary,dateFrom,dateTo);
return dataToString(names, finalSalary, dateFrom, dateTo);

resultString.append(String.format("Report for period %s - %s",dateFrom,dateTo));
for (int i = 0; i < names.length; i++) {
resultString
.append(String.format(System.lineSeparator() + "%s - %d", names[i], salary[i]));

Choose a reason for hiding this comment

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

dont use String format, just use set of .append methods

}
return resultString.toString();
}

Choose a reason for hiding this comment

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

redundant blank line

Suggested change

@NadVlados
Copy link
Author

I can't declarate variables inline, because maven checkstile fails

Comment on lines 15 to 19
LocalDate date;
String nameOfEmployee;
int hours;
int salaryPerHour;
String[] personInformation;

Choose a reason for hiding this comment

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

not fixed. declare them inline

Suggested change
LocalDate date;
String nameOfEmployee;
int hours;
int salaryPerHour;
String[] personInformation;


private String dataToString(String[] names, int[] salary, String dateFrom, String dateTo) {
StringBuilder resultString = new StringBuilder();
resultString.append(String.format("Report for period %s - %s",dateFrom,dateTo));

Choose a reason for hiding this comment

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

not fixed.
image

for (int i = 0; i < names.length; i++) {
resultString
.append(System.lineSeparator())
.append(names[i]).append(" - ").append(salary[i]);

Choose a reason for hiding this comment

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

separate line for each append

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.

3 participants