From 0de9b669f8c0b31a4810d1f9d83ec9ef7c03fcc8 Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Wed, 11 Jan 2023 21:37:37 +0100 Subject: [PATCH] implemented restart button function --- src/main/java/Gui/GameGui.java | 1 + src/main/java/Gui/RestartGame.java | 20 +++++++++++++++++++ src/main/java/game/loadNextQuestion.java | 1 + .../compile/default-compile/inputFiles.lst | 19 +++++++++--------- .../default-testCompile/inputFiles.lst | 6 +++--- 5 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 src/main/java/Gui/RestartGame.java diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index b7246e2..5a35231 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -131,5 +131,6 @@ GridBagConstraints gbc; public void createRestartButton() { RestartBtn = new JButton("Neustarten"); LosingPanel.add(RestartBtn); + RestartBtn.addActionListener(new RestartGame()); } } diff --git a/src/main/java/Gui/RestartGame.java b/src/main/java/Gui/RestartGame.java new file mode 100644 index 0000000..83ee38c --- /dev/null +++ b/src/main/java/Gui/RestartGame.java @@ -0,0 +1,20 @@ +package Gui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class RestartGame implements ActionListener { + + StartGameGui restartGame = new StartGameGui(); + + @Override + public void actionPerformed(ActionEvent e) { + + GameGui.questionNr = 0; + GameGui.LosingPanel.setVisible(false); + restartGame.startGame(); + + + } + +} diff --git a/src/main/java/game/loadNextQuestion.java b/src/main/java/game/loadNextQuestion.java index 9bc63d8..60bca5e 100644 --- a/src/main/java/game/loadNextQuestion.java +++ b/src/main/java/game/loadNextQuestion.java @@ -59,6 +59,7 @@ public class loadNextQuestion implements ActionListener { public void wrongAnswer() { GameGui gameLose = new GameGui(); gameLose.createLosingPanel(); + gameLose.createRestartButton(); } } diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index e519c8c..aa9ecc7 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,9 +1,10 @@ -C:\Users\Leon\MiniGameProject\src\main\java\Gui\ActionHandler.java -C:\Users\Leon\MiniGameProject\src\main\java\game\loadNextQuestion.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\game\runGame.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\GameGui.java -C:\Users\Leon\MiniGameProject\src\main\java\Gui\GuiInterface.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\GuiInterface.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\RestartGame.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\GameGuiInterface.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\gui.java +C:\Users\ozan_\MiniGameProject\src\main\java\game\loadNextQuestion.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\ActionHandler.java +C:\Users\ozan_\MiniGameProject\src\main\java\main.java +C:\Users\ozan_\MiniGameProject\src\main\java\game\runGame.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\StartGameGui.java +C:\Users\ozan_\MiniGameProject\src\main\java\Gui\GameGui.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index 17c97ad..4d3e2e8 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -1,3 +1,3 @@ -C:\Users\Leon\MiniGameProject\src\test\java\Gui\guiTest.java -C:\Users\Leon\MiniGameProject\src\test\java\Gui\GameGuiTest.java -C:\Users\Leon\MiniGameProject\src\test\java\game\runGameTest.java +C:\Users\ozan_\MiniGameProject\src\test\java\Gui\GameGuiTest.java +C:\Users\ozan_\MiniGameProject\src\test\java\game\runGameTest.java +C:\Users\ozan_\MiniGameProject\src\test\java\Gui\guiTest.java