-
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
Implement method to calculate employee salaries #1282
base: master
Are you sure you want to change the base?
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.
Nice try! Before creating a PR please go through all the common mistakes
provided at the end of the task description, I left some comments, please implement them and then before re-requesting review make sure you don't make these most common mistakes.
https://github.com/mate-academy/jv-salary-info/blob/master/checklist.md
return salaryMap; | ||
} | ||
|
||
private String print(Map<String, Integer> salaryMap, |
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 name is a little misleading, print
usually means to print something on a console for example and don't return any value. Please change this name to something like createReport
.
public class SalaryInfo { | ||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.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.
make it a constant (private static final
)
LocalDate startDate = parseDate(dateFrom); | ||
LocalDate endDate = parseDate(dateTo); | ||
|
||
Map<String, Integer> salaryMap = initializeSalaryMap(names); |
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.
StringBuilder result = new StringBuilder(); | ||
result.append("Report for period ") | ||
.append(dateFrom).append(" - ") | ||
.append(dateTo).append("\n"); |
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.
LocalDate date = LocalDate.parse(parts[0], formatter); | ||
String name = parts[1]; | ||
int workHours = Integer.parseInt(parts[2]); | ||
int perHourRate = Integer.parseInt(parts[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.
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.
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, approved! See minor advice.
} | ||
|
||
} catch (Exception e) { | ||
System.err.println("Invalid data entry: " + entry); |
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.
If you want to catch an exception here, you should re-throw some custom exception/use RuntimeException
.
System.err.println("Invalid data entry: " + entry); | |
throw new RuntimeException("Invalid data entry: " + entry, e); |
No description provided.