From e9ec0251af68bf9e725ee611cdcb12d373369966 Mon Sep 17 00:00:00 2001 From: KEZEL BENOIT p1907091 Date: Sat, 4 Apr 2020 12:08:20 +0200 Subject: [PATCH 1/2] Creation of the ReadingFile method --- src/noteBook/NoteBook.java | 47 +++++++++++++++++++++++++++++++++++--- src/test/TestReading.java | 21 +++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/test/TestReading.java diff --git a/src/noteBook/NoteBook.java b/src/noteBook/NoteBook.java index 1c51645..ee47310 100644 --- a/src/noteBook/NoteBook.java +++ b/src/noteBook/NoteBook.java @@ -1,8 +1,49 @@ package noteBook; +import input.Gender; import input.Input; +import input.Person; +import input.Society; + +import java.io.File; +import java.io.IOException; +import java.util.Scanner; public class NoteBook { - Input inputs[]; - Input selected[]; -} + public Input[] inputs; + public Input[] selected; + + public void FileReading(String fileName) throws IOException { + File file = new File(fileName); + Scanner fileScanner = new Scanner(file); + int lines = 0; + while(fileScanner.hasNextLine()){ + lines++; + } + inputs = new Input[lines]; + fileScanner.reset(); + for (int i = 0; i Date: Sat, 4 Apr 2020 15:52:47 +0200 Subject: [PATCH 2/2] Changing method name replace by fileReading instead of FileReading --- src/noteBook/NoteBook.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/noteBook/NoteBook.java b/src/noteBook/NoteBook.java index ee47310..94f0aea 100644 --- a/src/noteBook/NoteBook.java +++ b/src/noteBook/NoteBook.java @@ -13,7 +13,7 @@ public class NoteBook { public Input[] inputs; public Input[] selected; - public void FileReading(String fileName) throws IOException { + public void fileReading(String fileName) throws IOException { File file = new File(fileName); Scanner fileScanner = new Scanner(file); int lines = 0;