diff --git a/src/main/java/game/runGame.java b/src/main/java/game/runGame.java index 747704a..8fb7550 100644 --- a/src/main/java/game/runGame.java +++ b/src/main/java/game/runGame.java @@ -10,8 +10,8 @@ public class runGame { public static String QuestionsPath = "QandA/Questions.txt"; public static String AnswersPath = "QandA/Answers.txt"; public static int lines = CountFileLines(QuestionsPath); - public static String[] arrQuestions = readFile(QuestionsPath); - public static String[] arrAnswers = readFile(AnswersPath); + public static String[] arrQuestions = readFile(QuestionsPath, lines); + public static String[] arrAnswers = readFile(AnswersPath, lines); public static String[] splitAns; public void run(int i) { @@ -40,9 +40,9 @@ public class runGame { } - public static String[] readFile(String Path) { + public static String[] readFile(String Path, int Lines) { BufferedReader reader; - String[] Arr = new String[lines]; + String[] Arr = new String[Lines]; try { reader = new BufferedReader(new FileReader(Path)); String line = reader.readLine(); diff --git a/src/test/java/game/runGameTest.java b/src/test/java/game/runGameTest.java index 0330d04..7af2aa0 100644 --- a/src/test/java/game/runGameTest.java +++ b/src/test/java/game/runGameTest.java @@ -47,7 +47,8 @@ class runGameTest { writer.write("Zeile 2\n"); writer.write("Zeile 3\n"); writer.close(); - String[] lines = runGame.readFile(file.getAbsolutePath()); + int numLine = runGame.CountFileLines(file.getAbsolutePath()); + String[] lines = runGame.readFile(file.getAbsolutePath(), numLine); assertEquals("Zeile 1", lines[0]); assertEquals("Zeile 2", lines[1]); assertEquals("Zeile 3", lines[2]);