#Feat - Produkte laden und dann Parsen zur berechnung für Order --> Coming soon!

main
Daniel Zikol 2025-12-13 21:33:21 +01:00
parent 76406349f7
commit 91cc4f9d03
1 changed files with 18 additions and 2 deletions

View File

@ -24,18 +24,33 @@ public class OnlineShop {
lager = new ArrayList<Product>();
}
public void loadProductsAndParse(ArrayList<String> lines){
for (int i = 1; i < lines.size(); i++){
String line = lines.get(i);
String[] partsOfList = lines.split(",");
int id = Integer.valueOf(partsOfList[0]);
String name = partsOfList[1];
double weight = Double.valueOf(partsOfList[2]);
double net = Double.valueOf(partsOfList[3]);
double mwst = Double.valueOf(partsOfList[4]);
int stock = Integer.valueOf(partsOfList[5]);
Product product = new Product(id,name,weight,net,mwst,stock);
lager.add(product);
}
}
public String[] produktListe() { String[] produkt = new String[lager.size()];
public String[] produktListe() {
String[] produkt = new String[lager.size()];
for (int i = 0; i < lager.size(); i++)
produkt[i] = lager.get(i).toString();
return produkt;
}
public static ArrayList<String> readFile(String path) throws FileNotFoundException {
ArrayList<String> lines = new ArrayList<>();
Scanner sc = new Scanner(new File(path));
while (sc.hasNextLine()) {
lines.add(sc.nextLine());
}
@ -43,4 +58,5 @@ public class OnlineShop {
sc.close();
return lines;
}
}