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) { if (e.getSource() == GameGui.RestartBtn) {
GameGui.questionNr = 0; GameGui.questionNr = 0;
GameGui.LosingPanel.setVisible(false); GameGui.LosingPanel.setVisible(false);
GameGui.counter = 1;
restartGame.startGame(); restartGame.startGame();
} }
if (e.getSource() == GameGui.RestartBtn1) { if (e.getSource() == GameGui.RestartBtn1) {
GameGui.questionNr = 0; GameGui.questionNr = 0;
GameGui.WinningPanel.setVisible(false); GameGui.WinningPanel.setVisible(false);
GameGui.counter = 1;
restartGame.startGame(); 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 JLabel Headline,QuestionLabel,WinningLabel, LosingLabel, ShowQuestionNr;
public static JButton AnswersBtn1,AnswersBtn2,AnswersBtn3,AnswersBtn4,RestartBtn,RestartBtn1,ClosingBtn; public static JButton AnswersBtn1,AnswersBtn2,AnswersBtn3,AnswersBtn4,RestartBtn,RestartBtn1,ClosingBtn;
public static int questionNr = 0; public static int questionNr = 0;
public static int counter = 1;
GridLayout grid; GridLayout grid;
GridBagConstraints gbc; GridBagConstraints gbc;
@ -103,9 +104,10 @@ GridBagConstraints gbc;
} }
@Override @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}; 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); ShowQuestionNr.setText(questionText);
MainPanel.add(ShowQuestionNr); MainPanel.add(ShowQuestionNr);

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

@ -18,6 +18,6 @@ public interface GameGuiInterface {
void createButtons(); 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 rungame = new runGame();
rungame.run(GameGui.questionNr); 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() { public void loadQuestions() {
if (GameGui.questionNr != runGame.arrQuestions.length - 1) { if (GameGui.questionNr != runGame.arrQuestions.length - 1) {
StartGame.run(GameGui.questionNr); StartGame.run(GameGui.questionNr);
gameStatus.createShowQuestion();
gameStatus.createShowQuestion(GameGui.questionNr);
} else { } else {
gameStatus.createWinningPanel(); gameStatus.createWinningPanel();
} }

Loading…
Cancel
Save