From b206ba0c91f3efe929785c3dc9660cbd3d6fce91 Mon Sep 17 00:00:00 2001 From: Sabine Gubitz Date: Thu, 24 Nov 2022 14:50:28 +0100 Subject: [PATCH] ReadData festgelegt --- src/GeneralMethods.java | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/GeneralMethods.java b/src/GeneralMethods.java index f862f88..1167648 100644 --- a/src/GeneralMethods.java +++ b/src/GeneralMethods.java @@ -14,26 +14,6 @@ import java.util.List; * @version 1.0 */ public class GeneralMethods { - - /**The method readData gives back an ArrayList from the data of a given file. - * - * @param pathRead the given filepath to read - * @return returns an ArrayList of Strings with the read data - */ - public static ArrayList readData(String pathRead){ - try { - ArrayList data = new ArrayList(); - List lines = Files.readAllLines(Paths.get(pathRead)); - for(String line : lines){ - data.add(line); - } - return data; - } catch (IOException e) { - e.printStackTrace(); - return new ArrayList(); - } - } - /**The method writeData saves the given data to a certain file. * * @param pathWrite the given filepath to write @@ -53,22 +33,21 @@ public class GeneralMethods { } /** - * Folgender Code von Sabine, zum gegen prüfen und entscheiden - */ - /** + * Author: Sabine Gubitz + * * The method read Data interprets a file and returns an useable list for other methods. * Files to be read have to use : as a divider between attributes * * @param pathRead determines the filename of the file that will be read * @return menueList, userList, orderList depending on Data read */ - public ArrayList readData2(String pathRead) { + public ArrayList readData(String pathRead) { Path path = Paths.get(pathRead); try { List rows = Files.readAllLines(path); - if (pathRead == "menue.csv") { + if (pathRead == "menue.txt") { ArrayList menueList = new ArrayList<>(); for (String row : rows) { @@ -85,7 +64,7 @@ public class GeneralMethods { } return menueList; - } else if (pathRead == "users.csv") { + } else if (pathRead == "users.txt") { ArrayList userList = new ArrayList<>(); for (String row : rows) { @@ -96,10 +75,11 @@ public class GeneralMethods { String billAddress = parts[2]; String phonenumber = parts[3]; String nameChildren = parts[4]; + String password = parts[5]; } return userList; - } else if (pathRead == "orders.csv") { + } else if (pathRead == "orders.txt") { ArrayList orderList = new ArrayList<>(); for (String row : rows) {