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

Salar info #1372

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

Conversation

Julianevinska
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 implementing the SalaryInfo class! 🎉 Your code effectively meets the task requirements, and you've demonstrated a solid understanding of Java concepts. Here are a few points to consider for improvement:

  • Input Validation: It's important to add validation for input parameters like names, data, startDate, and endDate to prevent potential NullPointerException or incorrect behavior. Ensuring these inputs are not null or empty will make your code more robust.

  • Exception Handling: While your code correctly throws an IllegalDateParametersException for logical date checks, remember to handle potential NumberFormatException when parsing integers. This will help manage unexpected input gracefully.

  • Cross-Platform Compatibility: Consider using System.lineSeparator() instead of \n for line separation to enhance cross-platform compatibility.

Your code is well-structured and follows good practices, with informative variable names and efficient use of StringBuilder. Keep up the great work, and make sure to address these points in future projects to continue improving your coding skills! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

private static final DateTimeFormatter DATE_FORMATTER
= DateTimeFormatter.ofPattern("dd.MM.yyyy");

public String getSalaryInfo(String[] names, String[] data, String startDate,

Choose a reason for hiding this comment

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

Consider adding validation for the input parameters names, data, startDate, and endDate to ensure they are not null or empty. This will prevent potential NullPointerException or incorrect behavior when the method is called with invalid inputs.


if (!entryDate.isBefore(start) && !entryDate.isAfter(end)) {
String employeeName = entryParts[1];
int hoursWorked = Integer.parseInt(entryParts[2]);

Choose a reason for hiding this comment

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

Parsing integers from strings can throw a NumberFormatException if the string is not a valid integer. Consider adding error handling to manage such cases gracefully.

if (!entryDate.isBefore(start) && !entryDate.isAfter(end)) {
String employeeName = entryParts[1];
int hoursWorked = Integer.parseInt(entryParts[2]);
int hourlyRate = Integer.parseInt(entryParts[3]);

Choose a reason for hiding this comment

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

Similar to the previous comment, ensure that parsing the hourly rate does not throw a NumberFormatException by adding appropriate error handling.

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.

2 participants