public void delete(int id) throws NotExistException {
        ListElement current = this.getHead();
        ListElement previous = this.head;
        // delete element
        while (current != null) {
            if (current.getId() == id) {
                current = current.getNext();
                previous.setNext(current);
                count--;
                break;
            }
            previous = current;
            current = current.getNext();
        }
        current = this.getHead();
        if (current != null) {
            while (current.getNext() != null) {
                current = current.getNext();
            }
            this.tail = current;
        } else {
            throw new NotExistException("All robots are dead");
        }
    }