-
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
getSalaryInfo method was implemented #1259
base: master
Are you sure you want to change the base?
Conversation
LocalDate date; | ||
String nameOfEmployee; | ||
int hours; | ||
int salaryPerHour; | ||
int compareToDateFrom; | ||
int compareToDateTo; | ||
String[] personInformation; |
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.
declare it inline
LocalDate date; | |
String nameOfEmployee; | |
int hours; | |
int salaryPerHour; | |
int compareToDateFrom; | |
int compareToDateTo; | |
String[] personInformation; |
compareToDateFrom = localDateFrom.compareTo(date); | ||
compareToDateTo = localDateTo.compareTo(date); |
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 use isBefore and isAfter, it will improve your code readability
finalSalary[List.of(names).indexOf(nameOfEmployee)] += hours * salaryPerHour; | ||
} | ||
} | ||
return dataToString(names,finalSalary,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.
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])); |
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.
dont use String format, just use set of .append
methods
} | ||
return resultString.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.
redundant blank line
I can't declarate variables inline, because maven checkstile fails |
LocalDate date; | ||
String nameOfEmployee; | ||
int hours; | ||
int salaryPerHour; | ||
String[] personInformation; |
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.
not fixed. declare them inline
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)); |
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.
for (int i = 0; i < names.length; i++) { | ||
resultString | ||
.append(System.lineSeparator()) | ||
.append(names[i]).append(" - ").append(salary[i]); |
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.
separate line for each append
No description provided.