Skip to content

2-2-4-linked-list, contains()'s tests accept this wrong solution #168

Open
@obaibula

Description

@obaibula

The corrupted code:

@Override
    public boolean contains(T element) {
        requireNonNull(element);
        Node<T> current = head;

        if(!isEmpty()){
            while (current.next != null){
                if (current.element.equals(element)){
                    return true;
                }
                current = current.next;
            }
        }

        return false;
    }

It would be great to check in tests for the presence of the last element in the list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions