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

solution #1554

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

solution #1554

wants to merge 2 commits into from

Conversation

ivanlavrinenko
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.


Thank you for your hard work on this ArrayList implementation! 😊 There are a couple of critical issues that need to be addressed before we can approve the pull request:

  1. Array Growth Factor: The task specifies that the internal array should grow by 1.5 times when full, but currently, it doubles in size. Please adjust this to meet the requirement.

  2. Custom Exception Definition: The ArrayListIndexOutOfBoundsException is used but not defined in the provided code. Make sure to implement or import this exception class to avoid runtime errors.

Once these issues are resolved, your implementation will be in great shape! Keep up the great work, and feel free to reach out if you have any questions. 🚀

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

Comment on lines 83 to 88
private void ensureCapacity(int minCapacity) {
if (minCapacity > elements.length) {
int newCapacity = Math.max(elements.length * 2, minCapacity);
elements = Arrays.copyOf(elements, newCapacity);
}
}

Choose a reason for hiding this comment

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

The ensureCapacity(int minCapacity) method is defined but not used anywhere in the class. Consider removing it if it's not needed, or ensure it's used appropriately if intended for future functionality.


private void validateIndex(int index) {
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("Index out of bounds: " + index);

Choose a reason for hiding this comment

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

The ArrayListIndexOutOfBoundsException is used here, but it is not defined in the provided code. Ensure that this exception class is implemented or imported correctly to avoid runtime errors.


private void validateIndexForAdd(int index) {
if (index < 0 || index > size) {
throw new ArrayListIndexOutOfBoundsException("Index out of bounds for add: " + index);

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 ArrayListIndexOutOfBoundsException is defined or imported correctly, as it is used here as well.

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.

Review Summary

Great effort on implementing the ArrayList! 🎉 You've made significant progress, especially with defining and using the ArrayListIndexOutOfBoundsException correctly. However, there are a couple of critical issues that need your attention:

  1. Array Growth Factor: The ensureCapacity method currently doubles the array size when it's full. According to the task requirements, the array should grow by 1.5 times its current size. Please adjust this logic to meet the specified requirement.

  2. Custom Exception: You've successfully implemented the ArrayListIndexOutOfBoundsException, which resolves the previous issue regarding the missing exception definition. Well done!

While the decision is to APPROVE this Pull Request to help you move forward with your learning, it's crucial to address the array growth logic in future iterations to ensure the functionality aligns with the task requirements. Keep up the good work, and continue to learn and improve from these experiences! 🚀

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

Comment on lines +78 to +80
private void ensureCapacity() {
if (size == elements.length) {
elements = Arrays.copyOf(elements, elements.length * 2);

Choose a reason for hiding this comment

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

The ensureCapacity method currently doubles the array size. According to the task requirements, the array should grow by 1.5 times when it's full. Please adjust the growth factor to meet the requirement.

@@ -0,0 +1,95 @@
package core.basesyntax;

import core.basesyntax.ArrayListIndexOutOfBoundsException;

Choose a reason for hiding this comment

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

The ArrayListIndexOutOfBoundsException is imported but not defined in the provided code. Ensure that this exception class is implemented or correctly imported to avoid runtime errors.

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