79 lines
2.3 KiB
Java
79 lines
2.3 KiB
Java
package Shop;
|
|
import Shop.Cart;
|
|
import Shop.Products;
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.util.ArrayList;
|
|
import java.util.Scanner;
|
|
|
|
public class OnlineShop {
|
|
private ArrayList<Products> warehouse;
|
|
|
|
public OnlineShop throws FileNotFoundException { //readFile-Methode
|
|
warehouse = new ArrayList<>();
|
|
|
|
//Einlesen
|
|
Scanner scan = new Scanner(new File("resources/produkte.csv")); //Scanner erstellen
|
|
scan.nextLine();
|
|
|
|
while (scan.hasNextLine()) { //Solange da noch Zeilen im Dokument sind...
|
|
String Line = scan.nextLine().trim();
|
|
|
|
if (Line.length() == 5) {
|
|
String[] Parts = Line.split(",");
|
|
|
|
int productID = Integer.parseInt(Parts[0]);
|
|
String Name = Parts[1];
|
|
double weight = Double.parseDouble(Parts[2]);
|
|
double netWorth = Double.parseDouble(Parts[3]);
|
|
double tax = Double.parseDouble(Parts[4]);
|
|
int stock = Integer.parseInt(Parts[5]);
|
|
|
|
Products prod = new Products(Name, weight, netWorth, tax, stock, productID);
|
|
warehouse.add(prod);
|
|
}}
|
|
|
|
scan.close();
|
|
}
|
|
public String[] ProductList() {
|
|
String[] productList = new String [warehouse.size()];
|
|
for (int i = 0; i < warehouse.size(); i++) {
|
|
productList[i] = warehouse.get(i).toString();
|
|
}
|
|
|
|
return productList;
|
|
}
|
|
|
|
public class Order {
|
|
private String Name;
|
|
private String Adress;
|
|
private Cart cart;
|
|
private double wholeAmount;
|
|
|
|
public Order(String Name, String Adress, Cart cart, double wholeAmount) {
|
|
this.Name = Name;
|
|
this.Adress = Adress;
|
|
this.cart = cart;
|
|
this.wholeAmount = wholeAmount;
|
|
}
|
|
|
|
public String getName() {
|
|
return Name;
|
|
}
|
|
|
|
public String getAdresse() {
|
|
return Adress;
|
|
}
|
|
|
|
public Cart getCart() {
|
|
return cart;
|
|
}
|
|
|
|
public double wholeAmount() {
|
|
return wholeAmount;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |