Browse Source

refactoring: Formating Code

master
Leon Montag 2 years ago
parent
commit
3e6c043e22
  1. 1
      src/main/java/Gui/ActionHandler.java
  2. 2
      src/main/java/Gui/StartGameGui.java
  3. 4
      src/main/java/Gui/gui.java
  4. 4
      src/main/java/game/runGame.java
  5. 3
      src/test/java/Gui/guiTest.java
  6. 3
      src/test/java/game/runGameTest.java
  7. 2
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

1
src/main/java/Gui/ActionHandler.java

@ -3,7 +3,6 @@ package Gui;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
public class ActionHandler implements ActionListener { public class ActionHandler implements ActionListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

2
src/main/java/Gui/StartGameGui.java

@ -5,7 +5,6 @@ import java.awt.event.ActionListener;
import game.runGame; import game.runGame;
public class StartGameGui implements ActionListener { public class StartGameGui implements ActionListener {
@Override @Override
@ -13,6 +12,7 @@ public class StartGameGui implements ActionListener {
gui.Panel.setVisible(false); gui.Panel.setVisible(false);
startGame(); startGame();
} }
public void startGame() { public void startGame() {
GameGuiInterface Gui = new GameGui(); GameGuiInterface Gui = new GameGui();
Gui.createGui(); Gui.createGui();

4
src/main/java/Gui/gui.java

@ -23,6 +23,7 @@ public class gui implements GuiInterface {
createButtons(); createButtons();
createPanel(); createPanel();
} }
@Override @Override
public void createFrame() { public void createFrame() {
Frame = new JFrame("MiniGames"); Frame = new JFrame("MiniGames");
@ -39,8 +40,8 @@ public class gui implements GuiInterface {
CloseBtn = new JButton("Schließen"); CloseBtn = new JButton("Schließen");
CloseBtn.addActionListener(new ActionHandler()); CloseBtn.addActionListener(new ActionHandler());
} }
@Override @Override
public void createPanel() { public void createPanel() {
Panel = new JPanel(); Panel = new JPanel();
@ -63,5 +64,4 @@ public class gui implements GuiInterface {
Panel.setVisible(true); Panel.setVisible(true);
} }
} }

4
src/main/java/game/runGame.java

@ -14,7 +14,6 @@ public class runGame {
public static String[] arrAnswers = readFile(AnswersPath); public static String[] arrAnswers = readFile(AnswersPath);
public static String[] splitAns; public static String[] splitAns;
public void run(int i) { public void run(int i) {
splitAns = SplitAnswers(arrAnswers, i); splitAns = SplitAnswers(arrAnswers, i);
GameGui.QuestionLabel.setText(arrQuestions[i]); GameGui.QuestionLabel.setText(arrQuestions[i]);
@ -24,6 +23,7 @@ public class runGame {
GameGui.AnswersBtn4.setText(splitAns[3]); GameGui.AnswersBtn4.setText(splitAns[3]);
GameGui.questionNr++; GameGui.questionNr++;
} }
public static int CountFileLines(String Path) { public static int CountFileLines(String Path) {
int Numlines = 0; int Numlines = 0;
try { try {
@ -39,6 +39,7 @@ public class runGame {
return Numlines + 1; return Numlines + 1;
} }
public static String[] readFile(String Path) { public static String[] readFile(String Path) {
BufferedReader reader; BufferedReader reader;
String[] Arr = new String[lines]; String[] Arr = new String[lines];
@ -57,6 +58,7 @@ public class runGame {
} }
return Arr; return Arr;
} }
public static String[] SplitAnswers(String[] data2, int i) { public static String[] SplitAnswers(String[] data2, int i) {
String[] parts = data2[i].split(","); String[] parts = data2[i].split(",");
return parts; return parts;

3
src/test/java/Gui/guiTest.java

@ -22,6 +22,7 @@ class guiTest {
assertEquals(FrameWitdh, gui.Frame.getWidth()); assertEquals(FrameWitdh, gui.Frame.getWidth());
assertEquals(FrameHeight, gui.Frame.getHeight()); assertEquals(FrameHeight, gui.Frame.getHeight());
} }
@Test @Test
public void testCreateButtons() { public void testCreateButtons() {
// arrange // arrange
@ -49,6 +50,4 @@ class guiTest {
assertEquals(NumPanels, TargetNumPanels); assertEquals(NumPanels, TargetNumPanels);
} }
} }

3
src/test/java/game/runGameTest.java

@ -56,8 +56,8 @@ class runGameTest {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Test @Test
public void testSplitAnswers() { public void testSplitAnswers() {
String[] StringToSplit = { "Das,ist,ein,Test", "1,2,3,4" }; String[] StringToSplit = { "Das,ist,ein,Test", "1,2,3,4" };
@ -69,5 +69,4 @@ class runGameTest {
assertEquals("4", parts[3]); assertEquals("4", parts[3]);
} }
} }

2
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@ -1,6 +1,8 @@
C:\Users\Leon\MiniGameProject\src\main\java\Gui\ActionHandler.java C:\Users\Leon\MiniGameProject\src\main\java\Gui\ActionHandler.java
C:\Users\Leon\MiniGameProject\src\main\java\Gui\GameGuiInterface.java
C:\Users\Leon\MiniGameProject\src\main\java\Gui\gui.java C:\Users\Leon\MiniGameProject\src\main\java\Gui\gui.java
C:\Users\Leon\MiniGameProject\src\main\java\game\runGame.java C:\Users\Leon\MiniGameProject\src\main\java\game\runGame.java
C:\Users\Leon\MiniGameProject\src\main\java\main.java C:\Users\Leon\MiniGameProject\src\main\java\main.java
C:\Users\Leon\MiniGameProject\src\main\java\Gui\StartGameGui.java C:\Users\Leon\MiniGameProject\src\main\java\Gui\StartGameGui.java
C:\Users\Leon\MiniGameProject\src\main\java\Gui\GameGui.java C:\Users\Leon\MiniGameProject\src\main\java\Gui\GameGui.java
C:\Users\Leon\MiniGameProject\src\main\java\Gui\GuiInterface.java
Loading…
Cancel
Save