From 76736f610baeb0ef6bf25bbb84d079e1a5e02776 Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Fri, 13 Jan 2023 16:18:07 +0100 Subject: [PATCH] implemented functionality for showing current question --- src/main/java/Gui/ActionHandler.java | 2 ++ src/main/java/Gui/GameGui.java | 6 ++++-- src/main/java/Gui/GameGuiInterface.java | 2 +- src/main/java/Gui/StartGameGui.java | 2 +- src/main/java/game/loadNextQuestion.java | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/Gui/ActionHandler.java b/src/main/java/Gui/ActionHandler.java index 9eca7bb..2ee890f 100644 --- a/src/main/java/Gui/ActionHandler.java +++ b/src/main/java/Gui/ActionHandler.java @@ -19,12 +19,14 @@ public class ActionHandler implements ActionListener { if (e.getSource() == GameGui.RestartBtn) { GameGui.questionNr = 0; GameGui.LosingPanel.setVisible(false); + GameGui.counter = 1; restartGame.startGame(); } if (e.getSource() == GameGui.RestartBtn1) { GameGui.questionNr = 0; GameGui.WinningPanel.setVisible(false); + GameGui.counter = 1; restartGame.startGame(); } diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index 2d4af82..a005f4e 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -19,6 +19,7 @@ public static JPanel MainPanel, ButtonPanel, headingPanel, WinningPanel, LosingP public static JLabel Headline,QuestionLabel,WinningLabel, LosingLabel, ShowQuestionNr; public static JButton AnswersBtn1,AnswersBtn2,AnswersBtn3,AnswersBtn4,RestartBtn,RestartBtn1,ClosingBtn; public static int questionNr = 0; +public static int counter = 1; GridLayout grid; GridBagConstraints gbc; @@ -103,9 +104,10 @@ GridBagConstraints gbc; } @Override - public void createShowQuestion() { + public void createShowQuestion(int i) { int money[] = {10,20,30,40,50,60,70,80,90,100,110,120,130,140,150}; - String questionText = "Hier wird die Frage stehen"; + String questionText = "Frage " + counter + ": " + money[i - 1] + "€"; + counter++; ShowQuestionNr.setText(questionText); MainPanel.add(ShowQuestionNr); diff --git a/src/main/java/Gui/GameGuiInterface.java b/src/main/java/Gui/GameGuiInterface.java index c1fe85a..246ec83 100644 --- a/src/main/java/Gui/GameGuiInterface.java +++ b/src/main/java/Gui/GameGuiInterface.java @@ -18,6 +18,6 @@ public interface GameGuiInterface { void createButtons(); - void createShowQuestion(); + void createShowQuestion(int questionNr); } \ No newline at end of file diff --git a/src/main/java/Gui/StartGameGui.java b/src/main/java/Gui/StartGameGui.java index d811ace..c98e8d1 100644 --- a/src/main/java/Gui/StartGameGui.java +++ b/src/main/java/Gui/StartGameGui.java @@ -19,6 +19,6 @@ public class StartGameGui implements ActionListener { runGame rungame = new runGame(); rungame.run(GameGui.questionNr); - Gui.createShowQuestion(); + Gui.createShowQuestion(GameGui.questionNr); } } diff --git a/src/main/java/game/loadNextQuestion.java b/src/main/java/game/loadNextQuestion.java index a712fe9..83a8340 100644 --- a/src/main/java/game/loadNextQuestion.java +++ b/src/main/java/game/loadNextQuestion.java @@ -52,7 +52,7 @@ public class loadNextQuestion implements ActionListener { public void loadQuestions() { if (GameGui.questionNr != runGame.arrQuestions.length - 1) { StartGame.run(GameGui.questionNr); - gameStatus.createShowQuestion(); + gameStatus.createShowQuestion(GameGui.questionNr); } else { gameStatus.createWinningPanel(); }