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);
|
||||
}
|
||||
|
||||
public String getCurrentPuzzleName() {
|
||||
return currentPuzzleName;
|
||||
}
|
||||
|
||||
public void saveCurrentPuzzleHighscoreToFile() throws IOException {
|
||||
if (currentPuzzleName == null) return;
|
||||
String base = currentPuzzleName.replaceAll(".*/", "");
|
||||
|
|
|
@ -5,22 +5,24 @@ import de.deversmann.facade.Facade;
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class GameView extends JFrame {
|
||||
|
||||
private final Facade facade;
|
||||
private SpielfeldGUI spielfeldGUI;
|
||||
SpielfeldGUI spielfeldGUI;
|
||||
|
||||
private JComboBox<String> cbSpielfelder;
|
||||
private JButton btnLoad;
|
||||
private JButton btnRandom;
|
||||
private JButton btnCheckSolution;
|
||||
private JButton btnShowSolution;
|
||||
private JButton btnReset;
|
||||
private JLabel timeLabel;
|
||||
private Timer timer;
|
||||
JComboBox<String> cbSpielfelder;
|
||||
JButton btnLoad;
|
||||
JButton btnRandom;
|
||||
JButton btnCheckSolution;
|
||||
JButton btnShowSolution;
|
||||
JButton btnReset;
|
||||
JLabel timeLabel;
|
||||
Timer timer;
|
||||
|
||||
private final String[] spielfelder = {
|
||||
"4x4.csv",
|
||||
|
@ -96,7 +98,7 @@ public class GameView extends JFrame {
|
|||
timer.start();
|
||||
}
|
||||
|
||||
private void ladeSpielfeld(String pfad) {
|
||||
void ladeSpielfeld(String pfad) {
|
||||
try {
|
||||
facade.ladeSpielfeld(pfad);
|
||||
facade.loadCurrentPuzzleHighscoreFromFile();
|
||||
|
@ -115,7 +117,7 @@ public class GameView extends JFrame {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkSolution() {
|
||||
void checkSolution() {
|
||||
var blackCells = spielfeldGUI.getBlackCells();
|
||||
var solutionCoordinates = facade.getLoesungsKoordinaten();
|
||||
if (solutionCoordinates == null) {
|
||||
|
@ -199,7 +201,7 @@ public class GameView extends JFrame {
|
|||
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(",");
|
||||
int rr = Integer.parseInt(parts[0]);
|
||||
int cc = Integer.parseInt(parts[1]);
|
||||
|
@ -211,7 +213,7 @@ public class GameView extends JFrame {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void showSolution() {
|
||||
void showSolution() {
|
||||
var feld = facade.getAktuellesPuzzle();
|
||||
if (feld == null) return;
|
||||
spielfeldGUI.updateGrid(feld);
|
||||
|
@ -225,7 +227,7 @@ public class GameView extends JFrame {
|
|||
spielfeldGUI.setAllNonBlackToWhite();
|
||||
}
|
||||
|
||||
private void resetField() {
|
||||
void resetField() {
|
||||
var feld = facade.getAktuellesPuzzle();
|
||||
if (feld != null) {
|
||||
spielfeldGUI.updateGrid(feld);
|
||||
|
|
Loading…
Reference in New Issue