Introduction to OOP | Chapter 24: Design Patterns : | next | previous | audio | real | text |
class MyCollection implements Collection { public boolean isEmpty () { return data.count() == 0; } public int size () { return data.count(); } public void addElement (Object newElement) {data.add(newElement); } public boolean containsElement (Object test) { return data.find(test) != null; } public Object findElement (Object test) { return data.find(test); } private DataBox data = new DataBox(); }DataBox is some collection that does not support the Collection interface.