Browse Source

implemented functionality for showing current question

master
Ozan-Can Ekinci 2 years ago
parent
commit
76736f610b
  1. 2
      src/main/java/Gui/ActionHandler.java
  2. 6
      src/main/java/Gui/GameGui.java
  3. 2
      src/main/java/Gui/GameGuiInterface.java
  4. 2
      src/main/java/Gui/StartGameGui.java
  5. 2
      src/main/java/game/loadNextQuestion.java

2
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();
}

6
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);

2
src/main/java/Gui/GameGuiInterface.java

@ -18,6 +18,6 @@ public interface GameGuiInterface {
void createButtons();
void createShowQuestion();
void createShowQuestion(int questionNr);
}

2
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);
}
}

2
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();
}

Loading…
Cancel
Save