refactored testing
This commit is contained in:
parent
440eed0e9d
commit
e59cbb88f1
BIN
bin/test/oop/ch03/chess/ChessTest.class
Normal file
BIN
bin/test/oop/ch03/chess/ChessTest.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch05/generic/mensa/MensaTest.class
Normal file
BIN
bin/test/oop/ch05/generic/mensa/MensaTest.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch08/gui/mvc/TestModel.class
Normal file
BIN
bin/test/oop/ch08/gui/mvc/TestModel.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.class
Normal file
BIN
bin/test/oop/ch09/calc/test/AdHocCalculatorEdgePairTest.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.class
Normal file
BIN
bin/test/oop/ch09/calc/test/AdHocCalculatorEdgeTest.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch09/calc/test/CalculatorEdgePairTest.class
Normal file
BIN
bin/test/oop/ch09/calc/test/CalculatorEdgePairTest.class
Normal file
Binary file not shown.
BIN
bin/test/oop/ch09/testing/ExceptionTest.class
Normal file
BIN
bin/test/oop/ch09/testing/ExceptionTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung04/tournament/TournamentTest.class
Normal file
BIN
bin/test/uebung/uebung04/tournament/TournamentTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung05/logistics/ManagerTest.class
Normal file
BIN
bin/test/uebung/uebung05/logistics/ManagerTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class
Normal file
BIN
bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/junit-platform-console-standalone-1.11.0-M2.jar
Normal file
BIN
lib/junit-platform-console-standalone-1.11.0-M2.jar
Normal file
Binary file not shown.
@ -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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -1,9 +1,10 @@
|
|||||||
package iterator;
|
package test.uebung.uebung09.iterator;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
import uebung09.iterator.Array2dIterator;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
@ -1,10 +1,12 @@
|
|||||||
package iterator;
|
package test.uebung.uebung09.iterator;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import uebung09.iterator.*;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
@ -1,16 +1,16 @@
|
|||||||
package uebung09.chess;
|
package uebung09.chess;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import uebung09.iterator.Array2dIterator;
|
import uebung09.iterator.Array2dIterator;
|
||||||
|
|
||||||
public class Board extends Array2dIterator<Piece>{
|
|
||||||
private final Piece[][] field = new Piece[8][8];
|
|
||||||
private final List<Piece> pieces = new ArrayList<>();
|
|
||||||
|
|
||||||
Board(){
|
public class Board implements Iterable<Piece>{
|
||||||
|
private final Piece[][] field = new Piece[8][8];
|
||||||
}
|
//private final List<Piece> pieces = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
void add(Piece piece) {
|
void add(Piece piece) {
|
||||||
if (piece.getBoard() != this)
|
if (piece.getBoard() != this)
|
||||||
@ -42,7 +42,7 @@ public class Board extends Array2dIterator<Piece>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void check() {
|
public void check() {
|
||||||
for (Piece p1 : pieces) {
|
for (Piece p1 : iterator()) {
|
||||||
System.out.println(p1.toString());
|
System.out.println(p1.toString());
|
||||||
for (Piece p2 : pieces)
|
for (Piece p2 : pieces)
|
||||||
if (p1 != p2)
|
if (p1 != p2)
|
||||||
@ -56,4 +56,11 @@ public class Board extends Array2dIterator<Piece>{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return pieces.toString();
|
return pieces.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Piece> iterator() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new Array2dIterator<>(null);
|
||||||
|
//throw new UnsupportedOperationException("Unimplemented method 'iterator'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public class ChessApp {
|
|||||||
case WHITE_QUEEN -> addQueen(Color.white);
|
case WHITE_QUEEN -> addQueen(Color.white);
|
||||||
case BLACK_KNIGHT -> addKnight(Color.black);
|
case BLACK_KNIGHT -> addKnight(Color.black);
|
||||||
case WHITE_KNIGHT -> addKnight(Color.white);
|
case WHITE_KNIGHT -> addKnight(Color.white);
|
||||||
|
case ITERATOR -> board.iterator();
|
||||||
default -> System.out.println("Invalid command " + command);
|
default -> System.out.println("Invalid command " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,36 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
public class Array2dIterator<T> implements Iterator<T>{
|
public class Array2dIterator<T> implements Iterator<T>{
|
||||||
|
|
||||||
|
private T[][] array;
|
||||||
|
private int index = 0;
|
||||||
|
|
||||||
public <T> Array2dIterator(T[][] aaray) {
|
public Array2dIterator(T[][] array) {
|
||||||
|
this.array = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T next() {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user