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 static String QuestionsPath = "QandA/Questions.txt";
public static String AnswersPath = "QandA/Answers.txt";
public static int lines;
public void run() {
CountFileLines(QuestionsPath);
readFile(QuestionsPath);
}
public long CountFileLines(String Path) {
public int CountFileLines(String Path) {
try {
BufferedReader reader = new BufferedReader(new FileReader(Path));
while (reader.readLine() != null) {
lines++;
}
} catch (IOException e) {
e.printStackTrace();
}
return 0;
return lines;
}
public static String[] readFile(String Path) {
BufferedReader reader;
String[] Arr = new String[6];
String[] Arr = new String[lines];
try {
reader = new BufferedReader(new FileReader(Path));
String line = reader.readLine();

BIN
target/MiniGameProject-1.0-SNAPSHOT.jar

2
target/maven-archiver/pom.properties

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