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

https://github.com/DmytroBorysenko2004/jv-array-list #1515

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

Conversation

DmytroBorysenko2004
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 implementation! While your code meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Abstract Class Declaration: The ArrayList class is currently declared as abstract, which prevents it from being instantiated. Since it implements all methods from the List interface, consider removing the abstract keyword.

  2. add Method with Index: The current implementation does not allow adding elements at the end of the list (i.e., at index size). Please modify the rangeCheck method or add a condition to allow this.

  3. remove(Object element) Method: This method should not throw a NoSuchElementException if the element is not found. Instead, it should return false, which is the standard behavior for a List.

  4. addAll Method: Ensure that the method checks if the input list is null to avoid a NullPointerException.

Once these issues are resolved, your implementation will be much stronger and ready for approval. Keep up the great work, and I look forward to seeing your improvements! 😊

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

import java.util.List;
import java.util.NoSuchElementException;

public abstract class ArrayList<T> implements List<T> {

Choose a reason for hiding this comment

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

The class ArrayList is declared as abstract, but it implements all methods from the List interface. Consider removing the abstract keyword to allow instantiation of this class.

}

public void add(T value, int index) {
rangeCheck(index);

Choose a reason for hiding this comment

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

The rangeCheck method is used here, which will throw an exception if the index is equal to the size. However, adding at the end of the list (i.e., at index size) should be allowed. Consider modifying the rangeCheck method or adding a condition to allow this.

remove(index);
return true;
} else {
throw new NoSuchElementException("Element not found");

Choose a reason for hiding this comment

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

The remove(Object element) method should not throw a NoSuchElementException if the element is not found. Instead, it should return false, as this is the typical behavior for a List implementation.


public void addAll(List<T> list) {

Choose a reason for hiding this comment

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

The addAll method should check if the input list is null to avoid a NullPointerException. Consider adding a null check before proceeding with the method logic.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: 7]

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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 the ArrayList implementation! You've made significant progress, but there are still a few critical areas that need attention to fully meet the task requirements:

  1. Unimplemented Methods: Several methods such as set, addAll, contains, iterator, and toArray are not fully implemented. These methods are crucial for the functionality of the ArrayList and should be completed to align with the List interface requirements.

  2. add Method with Index: The add(T value, int index) method currently does not allow adding elements at the end of the list. Consider modifying the rangeCheck method or adding a condition to permit this.

  3. addAll Method: Ensure to add a null check for the input list to prevent a NullPointerException.

Despite these issues, the decision is to APPROVE your Pull Request to help you move forward with your learning journey. Please review the comments and address these critical issues in future iterations to enhance your code's functionality and robustness. Keep up the great work and continue improving your skills! 🚀

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

Comment on lines +36 to +37
public void add(T value, int index) {
rangeCheck(index);

Choose a reason for hiding this comment

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

The rangeCheck method is used here, which does not allow adding elements at the end of the list (i.e., at index size). Consider modifying the rangeCheck method or adding a condition to allow adding at the end.

size++;
}

public void addAll(List<T> list) {

Choose a reason for hiding this comment

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

The addAll method should check if the input list is null to avoid a NullPointerException. Consider adding a null check before proceeding with the operation.

Comment on lines +58 to 59
public T set(int index, T element) {
return null;

Choose a reason for hiding this comment

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

The set method is not implemented and returns null. This method should update the element at the specified index and return the old element.

Comment on lines +100 to +101
public boolean addAll(Collection<? extends T> c) {
return false;

Choose a reason for hiding this comment

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

The addAll method is not implemented and returns false. This method should add all elements from the specified collection to the list.

Comment on lines +135 to 136
public boolean contains(Object o) {
return false;

Choose a reason for hiding this comment

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

The contains method is not implemented and returns false. This method should check if the list contains the specified element.

Comment on lines +140 to +141
public Iterator<T> iterator() {
return null;

Choose a reason for hiding this comment

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

The iterator method is not implemented and returns null. This method should return an iterator over the elements in the list.

Comment on lines +145 to +146
public Object[] toArray() {
return new Object[0];

Choose a reason for hiding this comment

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

The toArray method is not implemented and returns an empty array. This method should return an array containing all elements in the list.

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