+ JUnit
+ Tests für Warenkorb: Hinzufügen, Menge ändern, Entfernen und Leerzustandmain
parent
f11dcbf4ef
commit
e36320e6bf
|
|
@ -13,8 +13,7 @@ public class OnlineShop {
|
|||
lager = new ArrayList<Produkt>();
|
||||
|
||||
Scanner sc = new Scanner(new File("././resources/produkte.csv"));
|
||||
|
||||
if (sc.hasNextLine()) sc.nextLine();
|
||||
sc.nextLine();
|
||||
|
||||
while(sc.hasNextLine() ) {
|
||||
String zeile = sc.nextLine();
|
||||
|
|
@ -28,7 +27,6 @@ public class OnlineShop {
|
|||
int bestand = Integer.parseInt(teile[5]);
|
||||
|
||||
Produkt p = new Produkt(id, name, gewicht, preis, mwst, bestand);
|
||||
|
||||
lager.add(p);
|
||||
}
|
||||
sc.close();
|
||||
|
|
|
|||
|
|
@ -2,20 +2,15 @@ package backend;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class Warenkorb {
|
||||
private ArrayList<Produkt> inhalt;
|
||||
private ArrayList<WarenkorbPosition> positionen;
|
||||
|
||||
|
||||
public Warenkorb() {
|
||||
inhalt = new ArrayList<Produkt>();
|
||||
positionen = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public void produktHinzufügen(Produkt p, int menge) {
|
||||
for (int i = 0; i < menge; i++) {
|
||||
inhalt.add(p);
|
||||
}
|
||||
|
||||
boolean gefunden = false;
|
||||
for (WarenkorbPosition wp : positionen) {
|
||||
|
|
@ -37,7 +32,7 @@ public class Warenkorb {
|
|||
}
|
||||
|
||||
|
||||
public void pEntfernen(Produkt p) {
|
||||
public void entfernen(Produkt p) {
|
||||
ArrayList<WarenkorbPosition> neu = new ArrayList<>();
|
||||
|
||||
for (WarenkorbPosition wp : positionen) {
|
||||
|
|
@ -51,7 +46,7 @@ public class Warenkorb {
|
|||
|
||||
public boolean mengeAendern(Produkt p, int neu) {
|
||||
if (neu == 0) {
|
||||
this.pEntfernen(p);
|
||||
this.entfernen(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public class shopTUI {
|
|||
|
||||
if (neu == 0) {
|
||||
shop.erhöhen(p, alt);
|
||||
warenkorb.pEntfernen(p);
|
||||
warenkorb.entfernen(p);
|
||||
System.out.println("Die Position wurde gelöscht! ✧。٩(ˊᗜˋ)و✧*。");
|
||||
} else if (x > 0 && p.getBestand() < x) {
|
||||
System.out.println("Leider reicht unser Bestand nicht aus (˃̣̣̥ᯅ˂̣̣̥)");
|
||||
|
|
|
|||
Loading…
Reference in New Issue