Hallo. Ich soll in Java den Teil eines Minesweeperspiels programmieren, bei dem dem folgende Testfälle erfüllt werden, aber ich blick einfach nicht durch. Kann mir da jemand weiterhelfen?
Die Testfälle:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
public class MineFieldTest {
@test
public void initialeBreiteWirdGemerkt() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
int actualBreite = mf.getBreite();
assertEquals(breite, actualBreite);
}
@test
public void initialeHoeheWirdGemerkt() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
int actualHoehe = mf.getHoehe();
assertEquals(hoehe, actualHoehe);
}
@test
public void initialAlleFelderKeineBombe() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
for (int x = 0; x < breite; x++) {
for (int y = 0; y < hoehe; y++) {
assertFalse("Feld an [" + x + "," + y + "] darf keine Bombe haben", mf.hatBombe(x, y));
}
}
}
}
Die Testfälle:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
public class MineFieldTest {
@test
public void initialeBreiteWirdGemerkt() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
int actualBreite = mf.getBreite();
assertEquals(breite, actualBreite);
}
@test
public void initialeHoeheWirdGemerkt() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
int actualHoehe = mf.getHoehe();
assertEquals(hoehe, actualHoehe);
}
@test
public void initialAlleFelderKeineBombe() {
int hoehe = 4;
int breite = 5;
MineField mf = new MineField(breite, hoehe);
for (int x = 0; x < breite; x++) {
for (int y = 0; y < hoehe; y++) {
assertFalse("Feld an [" + x + "," + y + "] darf keine Bombe haben", mf.hatBombe(x, y));
}
}
}
}