diff --git a/bin/test/oop/ch03/chess/ChessTest.class b/bin/test/oop/ch03/chess/ChessTest.class new file mode 100644 index 0000000..4a250b4 Binary files /dev/null and b/bin/test/oop/ch03/chess/ChessTest.class differ diff --git a/bin/test/oop/ch05/generic/mensa/MensaTest.class b/bin/test/oop/ch05/generic/mensa/MensaTest.class new file mode 100644 index 0000000..8550d09 Binary files /dev/null and b/bin/test/oop/ch05/generic/mensa/MensaTest.class differ diff --git a/bin/test/oop/ch08/gui/mvc/TestModel.class b/bin/test/oop/ch08/gui/mvc/TestModel.class new file mode 100644 index 0000000..82a0510 Binary files /dev/null and b/bin/test/oop/ch08/gui/mvc/TestModel.class differ diff --git a/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.class b/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.class new file mode 100644 index 0000000..1b5b8e4 Binary files /dev/null and b/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.class differ diff --git a/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.class b/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.class new file mode 100644 index 0000000..c474a6f Binary files /dev/null and b/bin/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.class differ diff --git a/bin/test/oop/ch09/calc/test/CalculatorEdgePairTest.class b/bin/test/oop/ch09/calc/test/CalculatorEdgePairTest.class new file mode 100644 index 0000000..1c664cc Binary files /dev/null and b/bin/test/oop/ch09/calc/test/CalculatorEdgePairTest.class differ diff --git a/bin/test/oop/ch09/testing/ExceptionTest.class b/bin/test/oop/ch09/testing/ExceptionTest.class new file mode 100644 index 0000000..c68f8a1 Binary files /dev/null and b/bin/test/oop/ch09/testing/ExceptionTest.class differ diff --git a/bin/test/uebung/uebung04/tournament/TournamentTest.class b/bin/test/uebung/uebung04/tournament/TournamentTest.class new file mode 100644 index 0000000..1e6e1d9 Binary files /dev/null and b/bin/test/uebung/uebung04/tournament/TournamentTest.class differ diff --git a/bin/test/uebung/uebung05/logistics/ManagerTest.class b/bin/test/uebung/uebung05/logistics/ManagerTest.class new file mode 100644 index 0000000..e26652b Binary files /dev/null and b/bin/test/uebung/uebung05/logistics/ManagerTest.class differ diff --git a/bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class b/bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class new file mode 100644 index 0000000..ab442b7 Binary files /dev/null and b/bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class differ diff --git a/bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class b/bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class new file mode 100644 index 0000000..298d863 Binary files /dev/null and b/bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class differ diff --git a/bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class b/bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class new file mode 100644 index 0000000..7ffe38f Binary files /dev/null and b/bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class differ diff --git a/bin/uebung09/chess/Board.class b/bin/uebung09/chess/Board.class index 8238078..bfa82bb 100644 Binary files a/bin/uebung09/chess/Board.class and b/bin/uebung09/chess/Board.class differ diff --git a/bin/uebung09/chess/ChessApp.class b/bin/uebung09/chess/ChessApp.class index caa1e54..9bbe5d7 100644 Binary files a/bin/uebung09/chess/ChessApp.class and b/bin/uebung09/chess/ChessApp.class differ diff --git a/bin/uebung09/iterator/Array2dIterator.class b/bin/uebung09/iterator/Array2dIterator.class index 6081202..6dff3bd 100644 Binary files a/bin/uebung09/iterator/Array2dIterator.class and b/bin/uebung09/iterator/Array2dIterator.class differ diff --git a/lib/junit-platform-console-standalone-1.11.0-M2.jar b/lib/junit-platform-console-standalone-1.11.0-M2.jar new file mode 100644 index 0000000..5c4bb1a Binary files /dev/null and b/lib/junit-platform-console-standalone-1.11.0-M2.jar differ diff --git a/test/oop/ch03/chess/ChessTest.java b/src/test/oop/ch03/chess/ChessTest.java similarity index 100% rename from test/oop/ch03/chess/ChessTest.java rename to src/test/oop/ch03/chess/ChessTest.java diff --git a/test/oop/ch05/generic/mensa/MensaTest.java b/src/test/oop/ch05/generic/mensa/MensaTest.java similarity index 100% rename from test/oop/ch05/generic/mensa/MensaTest.java rename to src/test/oop/ch05/generic/mensa/MensaTest.java diff --git a/test/oop/ch08/gui/mvc/TestModel.java b/src/test/oop/ch08/gui/mvc/TestModel.java similarity index 100% rename from test/oop/ch08/gui/mvc/TestModel.java rename to src/test/oop/ch08/gui/mvc/TestModel.java diff --git a/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.java b/src/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.java similarity index 100% rename from test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.java rename to src/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.java diff --git a/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.java b/src/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.java similarity index 100% rename from test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.java rename to src/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.java diff --git a/test/oop/ch09/calc/test/CalculatorEdgePairTest.java b/src/test/oop/ch09/calc/test/CalculatorEdgePairTest.java similarity index 100% rename from test/oop/ch09/calc/test/CalculatorEdgePairTest.java rename to src/test/oop/ch09/calc/test/CalculatorEdgePairTest.java diff --git a/test/oop/ch09/testing/ExceptionTest.java b/src/test/oop/ch09/testing/ExceptionTest.java similarity index 100% rename from test/oop/ch09/testing/ExceptionTest.java rename to src/test/oop/ch09/testing/ExceptionTest.java diff --git a/test/uebung/uebung04/tournament/TournamentTest.java b/src/test/uebung/uebung04/tournament/TournamentTest.java similarity index 100% rename from test/uebung/uebung04/tournament/TournamentTest.java rename to src/test/uebung/uebung04/tournament/TournamentTest.java diff --git a/test/uebung/uebung05/logistics/ManagerTest.java b/src/test/uebung/uebung05/logistics/ManagerTest.java similarity index 100% rename from test/uebung/uebung05/logistics/ManagerTest.java rename to src/test/uebung/uebung05/logistics/ManagerTest.java diff --git a/test/uebung/uebung05/logistics/storage/IntStorageTest.java b/src/test/uebung/uebung05/logistics/storage/IntStorageTest.java similarity index 96% rename from test/uebung/uebung05/logistics/storage/IntStorageTest.java rename to src/test/uebung/uebung05/logistics/storage/IntStorageTest.java index bc086ac..b6ca56a 100644 --- a/test/uebung/uebung05/logistics/storage/IntStorageTest.java +++ b/src/test/uebung/uebung05/logistics/storage/IntStorageTest.java @@ -1,6 +1,6 @@ -package logistics.storage; +package test.uebung.uebung05.logistics.storage; -import logistics.material.Oil; +import uebung05.*; import org.junit.Before; import org.junit.Test; diff --git a/test/uebung/uebung09/iterator/Array2dIteratorTest.java b/src/test/uebung/uebung09/iterator/Array2dIteratorTest.java similarity index 94% rename from test/uebung/uebung09/iterator/Array2dIteratorTest.java rename to src/test/uebung/uebung09/iterator/Array2dIteratorTest.java index 14e3a8e..3aca230 100644 --- a/test/uebung/uebung09/iterator/Array2dIteratorTest.java +++ b/src/test/uebung/uebung09/iterator/Array2dIteratorTest.java @@ -1,9 +1,10 @@ -package iterator; +package test.uebung.uebung09.iterator; import org.junit.Test; import java.util.Iterator; import java.util.NoSuchElementException; +import uebung09.iterator.Array2dIterator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/test/uebung/uebung09/iterator/SkipNullIteratorTest.java b/src/test/uebung/uebung09/iterator/SkipNullIteratorTest.java similarity index 98% rename from test/uebung/uebung09/iterator/SkipNullIteratorTest.java rename to src/test/uebung/uebung09/iterator/SkipNullIteratorTest.java index 372fb2c..2cb9541 100644 --- a/test/uebung/uebung09/iterator/SkipNullIteratorTest.java +++ b/src/test/uebung/uebung09/iterator/SkipNullIteratorTest.java @@ -1,10 +1,12 @@ -package iterator; +package test.uebung.uebung09.iterator; import org.junit.Test; import java.util.Iterator; import java.util.NoSuchElementException; +import uebung09.iterator.*; + import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; diff --git a/src/uebung09/chess/Board.java b/src/uebung09/chess/Board.java index 21e9b87..c14dd7f 100644 --- a/src/uebung09/chess/Board.java +++ b/src/uebung09/chess/Board.java @@ -1,16 +1,16 @@ package uebung09.chess; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; + import uebung09.iterator.Array2dIterator; -public class Board extends Array2dIterator{ - private final Piece[][] field = new Piece[8][8]; - private final List pieces = new ArrayList<>(); - Board(){ - - } +public class Board implements Iterable{ + private final Piece[][] field = new Piece[8][8]; + //private final List pieces = new ArrayList<>(); + void add(Piece piece) { if (piece.getBoard() != this) @@ -42,7 +42,7 @@ public class Board extends Array2dIterator{ } public void check() { - for (Piece p1 : pieces) { + for (Piece p1 : iterator()) { System.out.println(p1.toString()); for (Piece p2 : pieces) if (p1 != p2) @@ -56,4 +56,11 @@ public class Board extends Array2dIterator{ public String toString() { return pieces.toString(); } + + @Override + public Iterator iterator() { + // TODO Auto-generated method stub + return new Array2dIterator<>(null); + //throw new UnsupportedOperationException("Unimplemented method 'iterator'"); + } } diff --git a/src/uebung09/chess/ChessApp.java b/src/uebung09/chess/ChessApp.java index 1fe9baa..4dc1e1a 100644 --- a/src/uebung09/chess/ChessApp.java +++ b/src/uebung09/chess/ChessApp.java @@ -45,6 +45,7 @@ public class ChessApp { case WHITE_QUEEN -> addQueen(Color.white); case BLACK_KNIGHT -> addKnight(Color.black); case WHITE_KNIGHT -> addKnight(Color.white); + case ITERATOR -> board.iterator(); default -> System.out.println("Invalid command " + command); } } diff --git a/src/uebung09/iterator/Array2dIterator.java b/src/uebung09/iterator/Array2dIterator.java index 91909d4..7ca27e3 100644 --- a/src/uebung09/iterator/Array2dIterator.java +++ b/src/uebung09/iterator/Array2dIterator.java @@ -4,22 +4,36 @@ import java.util.Iterator; public class Array2dIterator implements Iterator{ + private T[][] array; + private int index = 0; - public Array2dIterator(T[][] aaray) { - + public Array2dIterator(T[][] array) { + this.array = array; } @Override public boolean hasNext() { - // TODO Auto-generated method stub + for (int i = 0; i < array.length; i++) { + for (int j = 0; j < array[i].length; j++) { + if (array[i][j+1] != null) { + return true; + } + if (array[i+1][j] != null) { + return true; + } + } + } return false; } @Override public T next() { - // TODO Auto-generated method stub + for (int i = 0; i < array.length; i++) { + for (int j = 0; j < array[i].length; j++) { + + } + } return null; } - }