From 74a5ee2946e31c8e047bd938a0026a40ec35c903 Mon Sep 17 00:00:00 2001 From: hertero Date: Thu, 1 Sep 2022 16:32:47 +0200 Subject: [PATCH] Anpassung der AbstractSimpleList-Klasse --- .../src/solution/AbstractSimpleList.java | 42 ++++++------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/SimpleLinkedList/src/solution/AbstractSimpleList.java b/SimpleLinkedList/src/solution/AbstractSimpleList.java index 9d5c60b..f17f608 100644 --- a/SimpleLinkedList/src/solution/AbstractSimpleList.java +++ b/SimpleLinkedList/src/solution/AbstractSimpleList.java @@ -2,42 +2,24 @@ package solution; import java.util.Collection; -public class AbstractSimpleList implements ISimpleList{ +public abstract class AbstractSimpleList implements ISimpleList { @Override - public int size() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean add(E e) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean add(Collection c) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean contains(Object o) { - // TODO Auto-generated method stub - return false; - } + public boolean add(Collection c) { + boolean temp = true; + for (E e : c) { + temp = temp && add(e); + } - @Override - public boolean remove(Object o) { - // TODO Auto-generated method stub - return false; + return temp; } @Override public void forAll(ICommand command) { - // TODO Auto-generated method stub - + if (command != null) { + for (int i = 0; i < size(); i++) { + command.execute(get(i)); + } + } } - }