Browse Source

implemented the line counting method

master
Leon Montag 2 years ago
parent
commit
407beaffc9
  1. 11
      src/main/java/game/runGame.java
  2. BIN
      target/MiniGameProject-1.0-SNAPSHOT.jar
  3. 2
      target/maven-archiver/pom.properties

11
src/main/java/game/runGame.java

@ -7,25 +7,28 @@ import java.io.IOException;
public class runGame { public class runGame {
public static String QuestionsPath = "QandA/Questions.txt"; public static String QuestionsPath = "QandA/Questions.txt";
public static String AnswersPath = "QandA/Answers.txt"; public static String AnswersPath = "QandA/Answers.txt";
public static int lines;
public void run() { public void run() {
CountFileLines(QuestionsPath); CountFileLines(QuestionsPath);
readFile(QuestionsPath); readFile(QuestionsPath);
} }
public long CountFileLines(String Path) {
public int CountFileLines(String Path) {
try { try {
BufferedReader reader = new BufferedReader(new FileReader(Path)); BufferedReader reader = new BufferedReader(new FileReader(Path));
while (reader.readLine() != null) {
lines++;
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return 0;
return lines;
} }
public static String[] readFile(String Path) { public static String[] readFile(String Path) {
BufferedReader reader; BufferedReader reader;
String[] Arr = new String[6];
String[] Arr = new String[lines];
try { try {
reader = new BufferedReader(new FileReader(Path)); reader = new BufferedReader(new FileReader(Path));
String line = reader.readLine(); String line = reader.readLine();

BIN
target/MiniGameProject-1.0-SNAPSHOT.jar

2
target/maven-archiver/pom.properties

@ -1,5 +1,5 @@
#Generated by Maven #Generated by Maven
#Fri Dec 30 11:45:27 CET 2022
#Fri Dec 30 12:02:39 CET 2022
groupId=MiniGameProject groupId=MiniGameProject
artifactId=MiniGameProject artifactId=MiniGameProject
version=1.0-SNAPSHOT version=1.0-SNAPSHOT
Loading…
Cancel
Save