Browse Source

Display the Question in the Gui

master
Leon Montag 2 years ago
parent
commit
903f92aaa1
  1. 1
      QandA/Questions.txt
  2. 1
      src/main/java/Gui/GameGui.java
  3. 2
      src/main/java/Gui/StartGameGui.java
  4. 20
      src/main/java/game/runGame.java

1
QandA/Questions.txt

@ -0,0 +1 @@
Wie hoch ist der Eifelturm?

1
src/main/java/Gui/GameGui.java

@ -16,6 +16,7 @@ public class GameGui {
public static JPanel MainPanel, ButtonPanel, headingPanel;
public static JLabel Headline,QuestionLabel;
public static JButton AnswersBtn1,AnswersBtn2,AnswersBtn3,AnswersBtn4;
public static int questionNr = 0;
GridLayout grid;
GridBagConstraints gbc;

2
src/main/java/Gui/StartGameGui.java

@ -15,7 +15,7 @@ public class StartGameGui implements ActionListener {
Gui.createGui();
runGame rungame = new runGame();
rungame.run();
rungame.run(GameGui.questionNr);
}
}

20
src/main/java/game/runGame.java

@ -4,25 +4,31 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import Gui.GameGui;
public class runGame {
public static String QuestionsPath = "QandA/Questions.txt";
public static String AnswersPath = "QandA/Answers.txt";
public static int lines;
public static int lines = CountFileLines(QuestionsPath);
public static String[] arrQuestions = readFile(QuestionsPath);
public static String[] arrAnswers = readFile(AnswersPath);
public void run() {
CountFileLines(QuestionsPath);
readFile(QuestionsPath);
public void run(int i) {
GameGui.QuestionLabel.setText(arrQuestions[i]);
}
public int CountFileLines(String Path) {
public static int CountFileLines(String Path) {
int Numlines = 0;
try {
BufferedReader reader = new BufferedReader(new FileReader(Path));
while (reader.readLine() != null) {
lines++;
Numlines++;
}
} catch (IOException e) {
e.printStackTrace();
}
return lines;
return Numlines;
}

Loading…
Cancel
Save