Browse Source

refactoring: extract Methods for Interface

master
Leon Montag 2 years ago
parent
commit
8e80ee7ad4
  1. 13
      src/main/java/Gui/GuiInterface.java
  2. 6
      src/main/java/Gui/gui.java
  3. 1
      src/main/java/game/runGame.java
  4. 3
      src/main/java/main.java
  5. 2
      src/test/java/Gui/guiTest.java

13
src/main/java/Gui/GuiInterface.java

@ -0,0 +1,13 @@
package Gui;
public interface GuiInterface {
void StartMainMenu();
void createFrame();
void createButtons();
void createPanel();
}

6
src/main/java/Gui/gui.java

@ -10,18 +10,20 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class gui {
public class gui implements GuiInterface {
public static JFrame Frame;
public static JButton StartBtn, CloseBtn;
public static JPanel Panel;
public static JLabel Label;
public static int width = 800, height = 600;
@Override
public void StartMainMenu() {
createFrame();
createButtons();
createPanel();
}
@Override
public void createFrame(){
Frame = new JFrame("MiniGames");
Frame.setSize(width,height);
@ -30,6 +32,7 @@ public class gui {
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void createButtons() {
StartBtn = new JButton("Starte Spiel");
StartBtn.addActionListener(new StartGameGui());
@ -38,6 +41,7 @@ public class gui {
}
@Override
public void createPanel() {
Panel = new JPanel();
Panel.setSize(width,height);

1
src/main/java/game/runGame.java

@ -39,7 +39,6 @@ public class runGame {
return Numlines+1;
}
public static String[] readFile(String Path) {
BufferedReader reader;
String[] Arr = new String[lines];

3
src/main/java/main.java

@ -1,11 +1,12 @@
import Gui.GuiInterface;
import Gui.gui;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
gui Mainmenu = new gui();
GuiInterface Mainmenu = new gui();
Mainmenu.StartMainMenu();
}

2
src/test/java/Gui/guiTest.java

@ -9,7 +9,7 @@ class guiTest {
@BeforeAll
static void setUp() {
gui StartGui = new gui();
GuiInterface StartGui = new gui();
StartGui.StartMainMenu();
}

Loading…
Cancel
Save