ReadData festgelegt

This commit is contained in:
Sabine Gubitz 2022-11-24 14:50:28 +01:00
parent 8d4851eecc
commit b206ba0c91

View File

@ -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<String> readData(String pathRead){
try {
ArrayList<String> data = new ArrayList<String>();
List<String> lines = Files.readAllLines(Paths.get(pathRead));
for(String line : lines){
data.add(line);
}
return data;
} catch (IOException e) {
e.printStackTrace();
return new ArrayList<String>();
}
}
/**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<String> readData2(String pathRead) {
public ArrayList<String> readData(String pathRead) {
Path path = Paths.get(pathRead);
try {
List<String> rows = Files.readAllLines(path);
if (pathRead == "menue.csv") {
if (pathRead == "menue.txt") {
ArrayList<String> 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<String> 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<String> orderList = new ArrayList<>();
for (String row : rows) {