"안녕하세요, 병사!"
"실력 향상을 축하합니다. 우리는 무엇이든 할 준비가 된 사람들이 필요합니다."
"아직 끝내지 못한 일이 많을 거라 확신합니다. 이제 그 중 일부를 끝낼 시간입니다!"
14
과제
Java Collections, 레벨 1, 레슨 15
Build a tree (part 1)
Amigo, it seems you may now have an adequate foundation. It's time to test your skills by doing a big task!
Today, we'll implement our own tree in a slightly non-standard way (based on AbstractList).
To get background information, use your favorite search engine and the text below.
14
과제
Java Collections, 레벨 1, 레슨 15
Build a tree (part 2)
Despite the fact that our tree descends from the AbstractList class, it is not a list in the traditional sense.
In particular, we don't have access to methods that take an element's index as an argument.
You need to override such methods and throw a new type of exception: UnsupportedOperationExcept
14
과제
Java Collections, 레벨 1, 레슨 15
Build a tree (part 3)
We've created a class that defines a tree. Now we need a class that defines the nodes of a tree:
1) In the CustomTree class, create a static inner generic class Entry<T> with the default access modifier.
2) Make this class support the Serializable interface.
28
과제
Java Collections, 레벨 1, 레슨 15
Build a tree (part 4)
Every tree starts with a root, so don't forget to add an Entry<String> field called root with the default access modifier to the CustomTree class. Initialize it in the CustomTree constructor. It's name (elementName) isn't important.
28
과제
Java Collections, 레벨 1, 레슨 15
Build a tree (part 5)
We can add elements to the tree. Now let's work on deleting them:
Implement the remove(Object o) method, which will remove the tree node whose name was passed as an argument.
The method must throw an UnsupportedOperationException if the argument is not a String.