#refactor - Namen refactored
#feat - @override Annotations hinzugefügt zu toString #feat - Steuer und Brutto preis rechnung hinzugefügt #feat - Lagerbestand setter hinzugefügtmain
parent
06d1e9bc0c
commit
48fc129967
|
|
@ -2,7 +2,7 @@ package shop;
|
|||
|
||||
/*
|
||||
TODO
|
||||
Setter getter tutorial schauen
|
||||
Setter getter tutorial schauen <----Erledigt
|
||||
|
||||
|
||||
|
||||
|
|
@ -13,15 +13,15 @@ public class Product {
|
|||
private double transportWeight;
|
||||
private double netPrice;
|
||||
private double mwst; // <----- Maybe final setzen
|
||||
private int lagerbestand;
|
||||
private int stock;
|
||||
|
||||
public Product(int prodID, String name, double transportWeight, double netPrice, double mwst, int lagerbestand) {
|
||||
public Product(int prodID, String name, double transportWeight, double netPrice, double mwst, int stock) {
|
||||
this.prodID = prodID;
|
||||
this.name = name;
|
||||
this.transportWeight = transportWeight;
|
||||
this.netPrice = netPrice;
|
||||
this.mwst = mwst;
|
||||
this.lagerbestand = lagerbestand;
|
||||
this.stock = stock;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -42,8 +42,8 @@ public class Product {
|
|||
return name;
|
||||
}
|
||||
|
||||
public int getLagerbestand() {
|
||||
return lagerbestand;
|
||||
public int getStock() {
|
||||
return stock;
|
||||
}
|
||||
|
||||
public int getProdID() {
|
||||
|
|
@ -61,21 +61,24 @@ public class Product {
|
|||
public double getTransportWeight() {
|
||||
return transportWeight;
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ID:" + prodID + " | " + name + " | " + netPrice + "€";
|
||||
return String.format("[%d] %-25s | %6.2f € Netto | Lager: %d", prodID, name, netPrice, stock);
|
||||
}
|
||||
|
||||
//mwst berechnung
|
||||
|
||||
//mwst berechnung ----> gibt nru die Steuer zurück
|
||||
public double mwstCalc() {
|
||||
double Steuerbetrag = this.netPrice * (19 / 100);
|
||||
return Math.round(Steuerbetrag * 100) / 100;
|
||||
|
||||
return Math.round(netPrice * (mwst / 100));
|
||||
}
|
||||
//Gibt preis versteuert zurück
|
||||
public double mwstOnPrice(){
|
||||
return Math.round(netPrice * (mwst / 100));
|
||||
}
|
||||
|
||||
public void setLagerbestand(int neuerLagerbestand) {
|
||||
this.lagerbestand = neuerLagerbestand;
|
||||
//Lagerbestand kann sich ändern. Einzige setter Methode
|
||||
public void setStock(int neuerLagerbestand) {
|
||||
this.stock = neuerLagerbestand;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue