Browse Source

refactoring: refactored createShowQuestion method

master
Ozan-Can Ekinci 2 years ago
parent
commit
1b0d11c9ad
  1. 23
      src/main/java/Gui/GameGui.java
  2. 2
      src/main/java/Gui/GameGuiInterface.java
  3. 2
      src/main/java/Gui/StartGameGui.java
  4. 2
      src/main/java/game/loadNextQuestion.java

23
src/main/java/Gui/GameGui.java

@ -21,6 +21,7 @@ public class GameGui implements GameGuiInterface {
public static int questionNr = 0; public static int questionNr = 0;
public static int currentQuestion = 1; public static int currentQuestion = 1;
public static int highScore = 0; public static int highScore = 0;
public static String Path ="QandA/Money.txt";
GridLayout grid; GridLayout grid;
GridBagConstraints gbc; GridBagConstraints gbc;
@ -104,17 +105,17 @@ public class GameGui implements GameGuiInterface {
} }
@Override @Override
public void createShowQuestion(int i) {
int numLines = runGame.CountFileLines("QandA/Money.txt");
String[] arrMoney = runGame.readFile("QandA/Money.txt", numLines);
String questionText = "Frage " + currentQuestion + ": " + arrMoney[i - 1] + " Euro";
currentQuestion++;
CurrentQuestionNrLabel.setText(questionText);
CurrentQuestionNrLabel.setFont(new Font("Serif", Font.BOLD, 20));
MainPanel.add(CurrentQuestionNrLabel);
}
public void createShowQuestion(int i, String Path) {
int numLines = runGame.CountFileLines(Path);
String[] arrMoney = runGame.readFile(Path, numLines);
String questionText = "Frage " + currentQuestion + ": " + arrMoney[i - 1] + " Euro";
currentQuestion++;
CurrentQuestionNrLabel.setText(questionText);
CurrentQuestionNrLabel.setFont(new Font("Serif", Font.BOLD, 20));
MainPanel.add(CurrentQuestionNrLabel);
}
@Override @Override
public void createHeadline() { public void createHeadline() {
HeadlineLabel = new JLabel("Wer wird Millionaer"); HeadlineLabel = new JLabel("Wer wird Millionaer");

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

@ -18,7 +18,7 @@ public interface GameGuiInterface {
void createButtons(); void createButtons();
void createShowQuestion(int questionNr);
void createShowQuestion(int questionNr, String Path);
void highScore(); void highScore();

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(GameGui.questionNr);
Gui.createShowQuestion(GameGui.questionNr, GameGui.Path);
} }
} }

2
src/main/java/game/loadNextQuestion.java

@ -49,7 +49,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(GameGui.questionNr);
gameStatus.createShowQuestion(GameGui.questionNr, GameGui.Path);
} else { } else {
gameStatus.createWinningPanel(); gameStatus.createWinningPanel();
} }

Loading…
Cancel
Save