Выполнены все пункты задания, может валидатор проверяет еще на что-то?
PS: после удаления ряда 3 - 6 , у элементов 1 - 2 восстановлена возможность иметь потомков. Смотрел дебагером.
Если была бы ошибка то не выполнился бы последний пункт теста ( левая ветка ):
The expected parent is 1. The actual parent is 1
The list size is 15
The expected parent is 3. The actual parent is 3
The expected parent is null. The actual parent is null
The expected parent is null. The actual parent is null
The expected parent is 9. The actual parent is 9
Expected: true. Actual: true
The expected parent is 1. The actual parent is 1
package com.javarush.task.task20.task2028;
import java.util.List;
public class Solution {
public static void main(String[] args) {
List<String> list = new CustomTree();
for (int i = 1; i < 16; i++) {
list.add(String.valueOf(i));
}
System.out.println("The list size is " + list.size());
System.out.println("The expected parent is 3. The actual parent is " + ((CustomTree) list).getParent("8"));
System.out.println("The expected parent is null. The actual parent is " + ((CustomTree) list).getParent("20"));
list.remove("3");
System.out.println("The expected parent is null. The actual parent is " + ((CustomTree) list).getParent("8"));
list.add("16");
System.out.println("The expected parent is 9. The actual parent is " + ((CustomTree) list).getParent("16"));
list.remove("4");
list.remove("5");
list.remove("6");
System.out.println("Expected: true. Actual: " + list.add("20"));
System.out.println("The expected parent is 1. The actual parent is " + ((CustomTree) list).getParent("20"));
}
}