Issue 6 und korrektur des Bestellvorgangs
parent
53acfa0eab
commit
e20ed20406
|
|
@ -2,58 +2,65 @@ package pack;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Bestellungen {
|
||||
public class Bestellung {
|
||||
String kundenName;
|
||||
String Addresse;
|
||||
Warenkorb wk;
|
||||
ArrayList<WarenkorbArtikel> warenkorb ;
|
||||
double Bruttopreis=0;
|
||||
double Bruttopreis;
|
||||
double versandkosten;
|
||||
boolean bestellungBestätigt;
|
||||
double gesamtPreis;
|
||||
double gesamtGewicht=0;
|
||||
double gesamtGewicht;
|
||||
double mwstGesamt; // hab die Aufgabe nicht verstanden bzw nicht umsetzten können
|
||||
|
||||
public Bestellungen(String kundenName,String Addresse,ArrayList<WarenkorbArtikel> warenkorb) {
|
||||
public Bestellung(String kundenName,String Addresse,ArrayList<WarenkorbArtikel> warenkorb) {
|
||||
this.kundenName=kundenName;
|
||||
this.Addresse=Addresse;
|
||||
this.warenkorb=warenkorb;
|
||||
this.Bruttopreis=berechnegBruttoPreis();
|
||||
this.bestellungBestätigt = true;
|
||||
this.gesamtGewicht=berechneGesamtGewicht();
|
||||
this.versandkosten=versandkostenBerechnen();
|
||||
this.gesamtPreis=Bruttopreis+versandkosten;
|
||||
|
||||
|
||||
|
||||
}
|
||||
public String toString(){
|
||||
return "Bestellung getätigt von"+ kundenName+" Lieferaddresse: "+Addresse+ " Preis: "+ Bruttopreis+ " zzgl. "+
|
||||
versandkosten+ " Versandkosten";
|
||||
return "Bestellung getätigt von "+ kundenName+" Lieferaddresse: "+Addresse+ " Preis: "+ Bruttopreis+"€"+ " zzgl. "+
|
||||
versandkosten+ " Versandkosten, insgesamt "+gesamtPreis+"€";
|
||||
|
||||
|
||||
}
|
||||
public double berechnegBruttoPreis(){
|
||||
double summe =0.0;
|
||||
for(int i=0;i<warenkorb.size();i++){
|
||||
Bruttopreis+= warenkorb.get(i).neuPreis;
|
||||
summe+= warenkorb.get(i).bruttopreis;
|
||||
}
|
||||
|
||||
|
||||
return Bruttopreis;
|
||||
return summe;
|
||||
}
|
||||
double berechneGesamtGewicht(){
|
||||
double gewicht = 0.0;
|
||||
for(int i=0;i<warenkorb.size();i++){
|
||||
gesamtGewicht+= warenkorb.get(i).gesamtGewicht;
|
||||
}return gesamtGewicht;
|
||||
gewicht+= warenkorb.get(i).gesamtGewicht;
|
||||
}return gewicht;
|
||||
}
|
||||
public double versandkostenBerechnen(){
|
||||
if(berechnegBruttoPreis()>=500){
|
||||
double brutto= berechnegBruttoPreis();
|
||||
double gewicht= berechneGesamtGewicht();
|
||||
|
||||
if(brutto>=500){
|
||||
return versandkosten=0.0;
|
||||
}
|
||||
if(100*berechneGesamtGewicht()<=100){
|
||||
if(1000*gewicht<=100){
|
||||
return versandkosten=3.95;
|
||||
} else if (berechneGesamtGewicht()+1000<=1000) {
|
||||
} else if (gewicht*1000<=1000) {
|
||||
return 4.95;
|
||||
|
||||
}else if (berechneGesamtGewicht()+1000<=5000) {
|
||||
}else if (gewicht*1000<=5000) {
|
||||
return 5.95;
|
||||
}else
|
||||
return 19.95;
|
||||
|
|
@ -119,11 +119,11 @@ public class OnlineShop {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Bestellungen bestellVorgang(String Name, String Addresse){
|
||||
Bestellungen bestellung= new Bestellungen(Name, Addresse, Artikel );
|
||||
ArrayList<WarenkorbArtikel> artikel =
|
||||
new ArrayList<>(warenkorb.ÜbertrageArtikel());
|
||||
Artikel.clear(); //Mit KI (2)
|
||||
public Bestellung bestellVorgang(String Name, String Addresse){
|
||||
ArrayList<WarenkorbArtikel> artikel = warenkorb.ÜbertrageArtikel();
|
||||
Bestellung bestellung= new Bestellung(Name, Addresse, artikel );
|
||||
|
||||
artikel.clear(); //Mit KI (2)
|
||||
|
||||
return bestellung;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class Produkt {
|
|||
this.ID=ID;
|
||||
this.mwstSatz=berechneMwst();
|
||||
this.bruttopreis=berechneBrutto();
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class Warenkorb {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public Produkt welchesProdukt(int vltID) {
|
||||
|
||||
for(Produkt p: produkte){
|
||||
|
|
|
|||
|
|
@ -5,23 +5,30 @@ public class WarenkorbArtikel {
|
|||
int Menge;
|
||||
double neuPreis;
|
||||
double gesamtGewicht;
|
||||
double bruttopreis;
|
||||
|
||||
public WarenkorbArtikel(Produkt produkt, int Menge) {
|
||||
this.produkt = produkt;
|
||||
this.Menge = Menge;
|
||||
this.neuPreis=berechneGesamtPreis();
|
||||
this.gesamtGewicht=berechneGesamtPreis();
|
||||
this.gesamtGewicht=berechneGesamtGewicht();
|
||||
this.bruttopreis=bruttoGesamtPreis();
|
||||
}
|
||||
public WarenkorbArtikel() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Produkt: " + produkt + ", Menge: " + Menge +", Brutto-Preis insgesamt:" +neuPreis +" davon Mwst: "+ produkt.mwstSatz*Menge; //Mit KI siehe (1)
|
||||
return "Produkt: " + produkt + ", Menge: " + Menge +", Bruttopreis:" + bruttoGesamtPreis()+"€ davon "+ produkt.mwstSatz*Menge +"€ Mwst , Nettopreis: "+ berechneGesamtPreis()+ "€ Gesamtgewicht: "+ berechneGesamtGewicht() +"kg"; //Mit KI siehe (1)
|
||||
}
|
||||
public static double berechneGesamtPreis(){
|
||||
if(Menge!=0){
|
||||
neuPreis= produkt.bruttopreis*Menge ;}
|
||||
else
|
||||
neuPreis=0;
|
||||
return neuPreis;
|
||||
public double berechneGesamtPreis(){
|
||||
return
|
||||
neuPreis= produkt.preis*Menge ;
|
||||
|
||||
}
|
||||
public double bruttoGesamtPreis(){
|
||||
double brutto= produkt.bruttopreis*Menge;
|
||||
return brutto;
|
||||
}
|
||||
public double berechneGesamtGewicht(){
|
||||
if(Menge==0){
|
||||
|
|
@ -31,4 +38,5 @@ public class WarenkorbArtikel {
|
|||
return gewicht;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -135,7 +135,8 @@ public class ShopTUI {
|
|||
String Name= sc.nextLine();
|
||||
IO.println("Addresse" );
|
||||
String Adresse= sc.nextLine();
|
||||
Bestellungen best=shop.bestellVorgang(Name,Adresse);
|
||||
Bestellung best=shop.bestellVorgang(Name,Adresse);
|
||||
|
||||
IO.println(best);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue