implementierung einer Bestellungs- und Warenkorbartikel-Klasse
parent
9e7b077820
commit
5709d78f5b
|
|
@ -0,0 +1,12 @@
|
|||
package pack;
|
||||
|
||||
public class Bestellungen {
|
||||
String kundenName;
|
||||
String Addresse;
|
||||
Warenkorb warenkorb;
|
||||
String Kaufdatum;
|
||||
double Preis;
|
||||
double versandkosten;
|
||||
String Zahlmethode;
|
||||
boolean bestellungBestätigt;
|
||||
}
|
||||
|
|
@ -4,31 +4,18 @@ package pack;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class Warenkorb {
|
||||
private ArrayList<Produkt> inhalt;
|
||||
private ArrayList<Produkt> Artikel;
|
||||
|
||||
public Warenkorb() {
|
||||
|
||||
inhalt = new ArrayList<Produkt>();
|
||||
Artikel = new ArrayList<Produkt>();
|
||||
|
||||
}
|
||||
|
||||
public void produktHinzufügen(Produkt p) {
|
||||
inhalt.add(p);
|
||||
Artikel.add(p);
|
||||
//Todo mit warenkorbartikel verknüpfen
|
||||
}
|
||||
|
||||
public double berechneGesamtpreis() {
|
||||
double preis = 0;
|
||||
|
||||
for (Produkt p : inhalt)
|
||||
preis+= p.preis;
|
||||
|
||||
return preis;
|
||||
}
|
||||
public double berechneGesamtGewicht() {
|
||||
double gewicht = 0;
|
||||
for (Produkt p : inhalt)
|
||||
gewicht+= p.Gewicht*1000; //für kg für den Versand
|
||||
return gewicht;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package pack;
|
||||
|
||||
public class WarenkorbArtikel {
|
||||
private Produkt produkt;
|
||||
private int Menge;
|
||||
|
||||
public WarenkorbArtikel(Produkt produkt, int Menge) {
|
||||
this.produkt = produkt;
|
||||
this.Menge = Menge;
|
||||
}
|
||||
public double berechneGesamtPreis(){
|
||||
double preis= produkt.preis*Menge;
|
||||
return preis;
|
||||
}
|
||||
public double berechneGesamtGewicht(){
|
||||
double gewicht= produkt.Gewicht*Menge;
|
||||
return gewicht;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -114,6 +114,11 @@ public class ShopTUI {
|
|||
//Todo hinzufügfen ermöglichen
|
||||
|
||||
}
|
||||
} public void MeinWarenkorb(){
|
||||
//Todo hier hinzufügen, entfernen oder menge ändern ermöglichen
|
||||
}
|
||||
public void bestellen(){
|
||||
//Hier alle infos wie name und addresse abfangen
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue