parent
d77718aa96
commit
b3269c7535
|
|
@ -1,54 +1,79 @@
|
|||
package Shop;
|
||||
public class OnlineShop{
|
||||
import Shop.Cart;
|
||||
import Shop.Products;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public static void main (String [] args){
|
||||
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();
|
||||
|
||||
public class Products{
|
||||
private String Name;
|
||||
private double weight;
|
||||
private double netWorth;
|
||||
private double tax;
|
||||
private int stock;
|
||||
while (scan.hasNextLine()) { //Solange da noch Zeilen im Dokument sind...
|
||||
String Line = scan.nextLine().trim();
|
||||
|
||||
// Constructor for the Products class
|
||||
public Products(String Name, double weight, double netWorth, double tax, int stock) {
|
||||
this.Name = Name;
|
||||
this.weight = weight;
|
||||
this.netWorth = netWorth;
|
||||
this.tax = tax;
|
||||
this.stock = stock;
|
||||
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 String getName(){
|
||||
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 double getWeight(){
|
||||
return weight;
|
||||
}
|
||||
public double getNetWorth(){
|
||||
return netWorth;
|
||||
}
|
||||
public double getTax(){
|
||||
return tax;
|
||||
}
|
||||
public int getStock(){
|
||||
return stock;
|
||||
|
||||
public String getAdresse() {
|
||||
return Adress;
|
||||
}
|
||||
|
||||
// Brutto Preis
|
||||
public double getGrossPrice(){
|
||||
return this.netWorth *(1+this.tax/100);
|
||||
public Cart getCart() {
|
||||
return cart;
|
||||
}
|
||||
|
||||
// Reine Steuer
|
||||
public double getTaxAmount(){
|
||||
return this.getGrossPrice()-this.netWorth;
|
||||
public double wholeAmount() {
|
||||
return wholeAmount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue