finish class Warenkorb
parent
6294762a56
commit
6352556d36
|
|
@ -28,9 +28,6 @@ public class OnlineShop {
|
|||
public void DelProduktAusWarenkorb(Produkt del){
|
||||
};
|
||||
public void ChangeProduktInWarenkorb(Produkt change, int count){
|
||||
};
|
||||
public void MoveProduktInWarenkorb(Produkt move, int direction){
|
||||
|
||||
};
|
||||
public void UpdateKundeInWarenkorb(Kunde neu){
|
||||
|
||||
|
|
|
|||
|
|
@ -13,22 +13,93 @@ public class Warenkorb {
|
|||
this.kunde = kunde;
|
||||
};
|
||||
|
||||
public int NettoPreis(){
|
||||
return 0;};
|
||||
public int BruttoPreis(){
|
||||
return 0;};
|
||||
public int NettoVersandkosten(){
|
||||
return 0;};
|
||||
public int BruttoVersandkosten(){
|
||||
return 0;};
|
||||
public int NettoGesamtPreis(){
|
||||
return 0;};
|
||||
public int BruttoGesamtPreis(){
|
||||
return 0;
|
||||
public Warenkorb() {
|
||||
this.inhalt = new ArrayList<Produkt>();
|
||||
this.anzahl = new ArrayList<Integer>();
|
||||
this.kunde = new Kunde("","");
|
||||
};
|
||||
public void AddProdukt(Produkt add, int count){};
|
||||
public void DelProdukt(Produkt del){};
|
||||
public void ChangeProdukt(Produkt change, int count){};
|
||||
public void MoveProdukt(Produkt move, int direction){};
|
||||
public void UpdateKunde(Kunde neu){};
|
||||
|
||||
public int NettoPreis(){
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (this.inhalt.get(i).netto*this.anzahl.get(i));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public int BruttoPreis(){
|
||||
double tmp = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
tmp += (this.inhalt.get(i).netto*this.anzahl.get(i)*(1+this.inhalt.get(i).mwStSatz));
|
||||
}
|
||||
return (int) Math.round(tmp);
|
||||
};
|
||||
public int NettoVersandkosten(){
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (((this.inhalt.get(i).netto*this.anzahl.get(i))/NettoPreis())*BruttoVersandkosten())/(1+this.inhalt.get(i).mwStSatz);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public int BruttoVersandkosten(){
|
||||
int ret = 0;
|
||||
int gewicht = Gewicht();
|
||||
if(gewicht >= 5000)
|
||||
ret = 1995;
|
||||
if(gewicht < 5000)
|
||||
ret = 595;
|
||||
if(gewicht < 1000)
|
||||
ret = 495;
|
||||
if(gewicht <= 100)
|
||||
ret = 395;
|
||||
return ret;
|
||||
};
|
||||
public int NettoGesamtPreis(){
|
||||
return NettoPreis()+NettoVersandkosten();
|
||||
};
|
||||
public int BruttoGesamtPreis(){
|
||||
return BruttoPreis()+BruttoVersandkosten();
|
||||
};
|
||||
public void AddProdukt(Produkt add, int count){
|
||||
this.inhalt.add(add);
|
||||
this.anzahl.add(count);
|
||||
CheckCount(add);
|
||||
};
|
||||
public void DelProdukt(Produkt del){
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(del.equals(this.inhalt.get(i))) {
|
||||
this.inhalt.remove(i);
|
||||
this.anzahl.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
public void ChangeProdukt(Produkt change, int count){
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(change.equals(this.inhalt.get(i))) {
|
||||
this.anzahl.set(i, count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
CheckCount(change);
|
||||
};
|
||||
public void UpdateKunde(Kunde neu){
|
||||
this.kunde = neu;
|
||||
};
|
||||
private void CheckCount(Produkt check) {
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(check.equals(this.inhalt.get(i))) {
|
||||
if(this.anzahl.get(i)<1) {
|
||||
DelProdukt(check);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private int Gewicht() {
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (this.inhalt.get(i).transportGewicht*this.anzahl.get(i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,5 @@ public class ShopTUI {
|
|||
}
|
||||
|
||||
private static void Menu(OnlineShop shop, Scanner sc) {
|
||||
shop.test = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,3 +20,5 @@ Time Chart:
|
|||
0:06 finish class Produkt
|
||||
|
||||
0:02 finish class Bestellung
|
||||
|
||||
0:38 finish class Warenkorb
|
||||
2
UML.svg
2
UML.svg
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Loading…
Reference in New Issue