From 6a1f5963dce49e22b7ffa03f2fde51a66d89f425 Mon Sep 17 00:00:00 2001 From: 3007492 <3007492@hs-mannheim.de> Date: Fri, 18 Oct 2024 15:09:58 +0200 Subject: [PATCH] =?UTF-8?q?verbesserung=20Warenkorb,=20Bestelllung=20hinzu?= =?UTF-8?q?gef=C3=BCgt,=20versandkosten=20Berechnung=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/de/hs_mannheim/informatik/.DS_Store | Bin 0 -> 6148 bytes .../informatik/rhenus/domain/Bestellung.java | 20 +++++++++++++++++ .../informatik/rhenus/domain/OnlineShop.java | 21 ++++++++++++++++++ .../informatik/rhenus/domain/Warenkorb.java | 12 ++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 OnlineShop2024/src/de/hs_mannheim/informatik/.DS_Store diff --git a/OnlineShop2024/src/de/hs_mannheim/informatik/.DS_Store b/OnlineShop2024/src/de/hs_mannheim/informatik/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4f63a7f75341fbcdf723991066ff484b4c35269d GIT binary patch literal 6148 zcmeHK!AiqG5S?wSO({YT3Oz1(En3?mikDdH!K)EHsMN+58;se~wDwR6IqMJkCH{`i z>~4fmy@^Pfftk0Nok=op!)^uuM0?ub1E>IigG!hyq4`E=o^(la){{pR`W{n=&q8(Y zhss}yX2*YIfYxpu#xR5dM37xS`Y4W3cRsY}*U!ZIvv_3J`pqAOK|HC~-$gE8SX(bT zMW^iCdP6nyCcVitZuiF5bakOr=%?eJe;EvB-OA>PiYC1v8jN*9&>vvP%~cTf)vT?i zQ9stXo|$k;PN`d|&gYGTMol)F%|%Vl4;%HGZ0)xei;}aoy?b=teGH!>^`hSz1b&}d zHY}#_ii1o|&)zr+RrG-VG$)N^WCoZ4W?)qqu=|@+UX_Bl4rYKE_%#M-e~_qzuEoTl z-a63e767q;ZY?;b-$u%j7F~;pL7YJmCKb`73fp1`la79A<6Mi0L6Z)`HXp)1S=bIm z=%?fTr49$-8f421FauczsP{vu(D{G*bN{b{*f0akz-lre3LUT0#@g)Jx>O~dwG#CX qm4xCFgI_5)&_^-G(otMR)q;LW14P$iVh}wj{3D=gV8aajDFdGy>{w#} literal 0 HcmV?d00001 diff --git a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Bestellung.java b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Bestellung.java index 6517598..53b6b94 100644 --- a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Bestellung.java +++ b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Bestellung.java @@ -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; + } } diff --git a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/OnlineShop.java b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/OnlineShop.java index c6374d6..39017e1 100644 --- a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/OnlineShop.java +++ b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/OnlineShop.java @@ -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; + } + } } diff --git a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Warenkorb.java b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Warenkorb.java index f863fe0..956816d 100644 --- a/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Warenkorb.java +++ b/OnlineShop2024/src/de/hs_mannheim/informatik/rhenus/domain/Warenkorb.java @@ -14,8 +14,8 @@ public class Warenkorb { return items; } - public ArrayList showWarenkorb(){ - return items; + public String showWarenkorb(){ + return items.toString(); } public ArrayList removeItem(Produkt p){ @@ -26,4 +26,12 @@ public class Warenkorb { public ArrayList getItems(){ return items; } + + public double gesamtPreis(){ + double gesamtpreis = 0; + for (Produkt produkt : items){ + gesamtpreis += produkt.getPreis(); + } + return gesamtpreis; + } }