feature(feature): Anpassungen für Tests
Anpassungen an Attributen der Klassen, um die Testbarkeit zu ermöglichenpull/4/head
parent
d67e9495ce
commit
ee20cea0eb
|
@ -78,10 +78,6 @@ public class Facade {
|
||||||
return highscoreManager.getAverageTime(currentPuzzleName);
|
return highscoreManager.getAverageTime(currentPuzzleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentPuzzleName() {
|
|
||||||
return currentPuzzleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveCurrentPuzzleHighscoreToFile() throws IOException {
|
public void saveCurrentPuzzleHighscoreToFile() throws IOException {
|
||||||
if (currentPuzzleName == null) return;
|
if (currentPuzzleName == null) return;
|
||||||
String base = currentPuzzleName.replaceAll(".*/", "");
|
String base = currentPuzzleName.replaceAll(".*/", "");
|
||||||
|
|
|
@ -5,22 +5,24 @@ import de.deversmann.facade.Facade;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class GameView extends JFrame {
|
public class GameView extends JFrame {
|
||||||
|
|
||||||
private final Facade facade;
|
private final Facade facade;
|
||||||
private SpielfeldGUI spielfeldGUI;
|
SpielfeldGUI spielfeldGUI;
|
||||||
|
|
||||||
private JComboBox<String> cbSpielfelder;
|
JComboBox<String> cbSpielfelder;
|
||||||
private JButton btnLoad;
|
JButton btnLoad;
|
||||||
private JButton btnRandom;
|
JButton btnRandom;
|
||||||
private JButton btnCheckSolution;
|
JButton btnCheckSolution;
|
||||||
private JButton btnShowSolution;
|
JButton btnShowSolution;
|
||||||
private JButton btnReset;
|
JButton btnReset;
|
||||||
private JLabel timeLabel;
|
JLabel timeLabel;
|
||||||
private Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
private final String[] spielfelder = {
|
private final String[] spielfelder = {
|
||||||
"4x4.csv",
|
"4x4.csv",
|
||||||
|
@ -96,7 +98,7 @@ public class GameView extends JFrame {
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ladeSpielfeld(String pfad) {
|
void ladeSpielfeld(String pfad) {
|
||||||
try {
|
try {
|
||||||
facade.ladeSpielfeld(pfad);
|
facade.ladeSpielfeld(pfad);
|
||||||
facade.loadCurrentPuzzleHighscoreFromFile();
|
facade.loadCurrentPuzzleHighscoreFromFile();
|
||||||
|
@ -115,7 +117,7 @@ public class GameView extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSolution() {
|
void checkSolution() {
|
||||||
var blackCells = spielfeldGUI.getBlackCells();
|
var blackCells = spielfeldGUI.getBlackCells();
|
||||||
var solutionCoordinates = facade.getLoesungsKoordinaten();
|
var solutionCoordinates = facade.getLoesungsKoordinaten();
|
||||||
if (solutionCoordinates == null) {
|
if (solutionCoordinates == null) {
|
||||||
|
@ -199,7 +201,7 @@ public class GameView extends JFrame {
|
||||||
JOptionPane.showMessageDialog(this, sb.toString(), "Ergebnis", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(this, sb.toString(), "Ergebnis", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsCell(List<int[]> blackCells, String sol) {
|
boolean containsCell(List<int[]> blackCells, String sol) {
|
||||||
String[] parts = sol.split(",");
|
String[] parts = sol.split(",");
|
||||||
int rr = Integer.parseInt(parts[0]);
|
int rr = Integer.parseInt(parts[0]);
|
||||||
int cc = Integer.parseInt(parts[1]);
|
int cc = Integer.parseInt(parts[1]);
|
||||||
|
@ -211,7 +213,7 @@ public class GameView extends JFrame {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSolution() {
|
void showSolution() {
|
||||||
var feld = facade.getAktuellesPuzzle();
|
var feld = facade.getAktuellesPuzzle();
|
||||||
if (feld == null) return;
|
if (feld == null) return;
|
||||||
spielfeldGUI.updateGrid(feld);
|
spielfeldGUI.updateGrid(feld);
|
||||||
|
@ -225,7 +227,7 @@ public class GameView extends JFrame {
|
||||||
spielfeldGUI.setAllNonBlackToWhite();
|
spielfeldGUI.setAllNonBlackToWhite();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetField() {
|
void resetField() {
|
||||||
var feld = facade.getAktuellesPuzzle();
|
var feld = facade.getAktuellesPuzzle();
|
||||||
if (feld != null) {
|
if (feld != null) {
|
||||||
spielfeldGUI.updateGrid(feld);
|
spielfeldGUI.updateGrid(feld);
|
||||||
|
|
Loading…
Reference in New Issue