verbesserung Warenkorb, Bestelllung hinzugefügt, versandkosten Berechnung hinzugefügt
parent
3e1ef78289
commit
6a1f5963dc
Binary file not shown.
|
@ -1,5 +1,25 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
public class Bestellung {
|
||||
private String adress;
|
||||
private String name;
|
||||
private String vorname;
|
||||
|
||||
public Bestellung(String adress, String name, String vorname){
|
||||
this.adress = adress;
|
||||
this.name = name;
|
||||
this.vorname = vorname;
|
||||
}
|
||||
|
||||
public String getAdress() {
|
||||
return adress;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVorname() {
|
||||
return vorname;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,25 @@ public class OnlineShop {
|
|||
|
||||
return w1;
|
||||
}
|
||||
|
||||
public Bestellung kundendatenEingeben(String adress, String name, String vorname){
|
||||
Bestellung b1 = new Bestellung(adress, name, vorname);
|
||||
return b1;
|
||||
}
|
||||
|
||||
public int versandkostenBerechnen(){
|
||||
double gesamtgewicht = 0;
|
||||
for(Produkt produkt : w1.getItems()){
|
||||
gesamtgewicht += produkt.getGewicht();
|
||||
}
|
||||
if (gesamtgewicht < 1000){
|
||||
return 5;
|
||||
}
|
||||
else if(gesamtgewicht > 1000 && gesamtgewicht < 2500){
|
||||
return 8;
|
||||
}
|
||||
else{
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class Warenkorb {
|
|||
return items;
|
||||
}
|
||||
|
||||
public ArrayList<Produkt> showWarenkorb(){
|
||||
return items;
|
||||
public String showWarenkorb(){
|
||||
return items.toString();
|
||||
}
|
||||
|
||||
public ArrayList<Produkt> removeItem(Produkt p){
|
||||
|
@ -26,4 +26,12 @@ public class Warenkorb {
|
|||
public ArrayList<Produkt> getItems(){
|
||||
return items;
|
||||
}
|
||||
|
||||
public double gesamtPreis(){
|
||||
double gesamtpreis = 0;
|
||||
for (Produkt produkt : items){
|
||||
gesamtpreis += produkt.getPreis();
|
||||
}
|
||||
return gesamtpreis;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue