parent
e20ed20406
commit
3343b13e27
|
|
@ -22,18 +22,13 @@ public class OnlineShop {
|
||||||
this.warenkorb = wk;
|
this.warenkorb = wk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String [][] Start() throws FileNotFoundException {
|
|
||||||
LagerList=readFile();
|
|
||||||
String [][]arr= produktArray(LagerList);
|
|
||||||
return arr;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String[][] produktArray(ArrayList Lagerlist) throws FileNotFoundException {
|
|
||||||
|
public String[][] produktArray() {
|
||||||
String[] Lager = new String[LagerList.size()];
|
String[] Lager = new String[LagerList.size()];
|
||||||
for (int i = 0; i < LagerList.size(); i++){
|
for (int i = 0; i < LagerList.size(); i++){
|
||||||
Lager[i] = LagerList.get(i);
|
Lager[i] = LagerList.get(i);
|
||||||
|
|
@ -52,8 +47,8 @@ public class OnlineShop {
|
||||||
|
|
||||||
return produktArray;
|
return produktArray;
|
||||||
}
|
}
|
||||||
public String[][] printArray() throws FileNotFoundException {
|
public String[][] printArray() {
|
||||||
String [][] arr = produktArray(LagerList);
|
String [][] arr = produktArray();
|
||||||
String[][] arrayForPrint = new String[arr.length][arr[0].length];
|
String[][] arrayForPrint = new String[arr.length][arr[0].length];
|
||||||
for(int i=0;i<arrayForPrint.length;i++){
|
for(int i=0;i<arrayForPrint.length;i++){
|
||||||
for(int j=0;j<arrayForPrint[i].length;j++){
|
for(int j=0;j<arrayForPrint[i].length;j++){
|
||||||
|
|
@ -86,7 +81,7 @@ public class OnlineShop {
|
||||||
|
|
||||||
public ArrayList<Produkt> ÜbertrageListe() throws FileNotFoundException {
|
public ArrayList<Produkt> ÜbertrageListe() throws FileNotFoundException {
|
||||||
LagerList=readFile();
|
LagerList=readFile();
|
||||||
String [][]arr= produktArray(LagerList);
|
String [][]arr= produktArray();
|
||||||
ArrayList<Produkt>ProduktListe=erstelleListe(arr);
|
ArrayList<Produkt>ProduktListe=erstelleListe(arr);
|
||||||
|
|
||||||
return ProduktListe;
|
return ProduktListe;
|
||||||
|
|
@ -110,7 +105,7 @@ public class OnlineShop {
|
||||||
ProduktListe=ÜbertrageListe();
|
ProduktListe=ÜbertrageListe();
|
||||||
return ProduktListe;
|
return ProduktListe;
|
||||||
}
|
}
|
||||||
public Produkt suchProdukt(String suche) throws FileNotFoundException {
|
public Produkt suchProdukt(String suche) {
|
||||||
for(Produkt p : ProduktListe){
|
for(Produkt p : ProduktListe){
|
||||||
if(p.name.equalsIgnoreCase(suche))
|
if(p.name.equalsIgnoreCase(suche))
|
||||||
return p;
|
return p;
|
||||||
|
|
@ -127,11 +122,6 @@ public class OnlineShop {
|
||||||
|
|
||||||
return bestellung;
|
return bestellung;
|
||||||
}
|
}
|
||||||
/* public void angepassterBestand() throws FileNotFoundException {
|
|
||||||
|
|
||||||
for (int i=0;i<Artikel.size();i++){
|
|
||||||
ProduktListe.get(i).Bestand-= Artikel.get(i).Menge;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,16 @@ class WarenkorbArtikelTest {
|
||||||
Produkt p5= new Produkt(15,"Wein",0.9,5.00,19,9);
|
Produkt p5= new Produkt(15,"Wein",0.9,5.00,19,9);
|
||||||
Produkt p6 = new Produkt(16,"Kaugummi",0.002,0.98,7,10);
|
Produkt p6 = new Produkt(16,"Kaugummi",0.002,0.98,7,10);
|
||||||
Produkt p7= new Produkt(18,"EuroSchein",0.002,100,5,10);
|
Produkt p7= new Produkt(18,"EuroSchein",0.002,100,5,10);
|
||||||
WarenkorbArtikel w1= new WarenkorbArtikel(p1,2);
|
WarenkorbArtikel w1= new WarenkorbArtikel(p1,2);
|
||||||
WarenkorbArtikel w2= new WarenkorbArtikel(p3,500);
|
WarenkorbArtikel w2= new WarenkorbArtikel(p3,500);
|
||||||
WarenkorbArtikel w3= new WarenkorbArtikel(p4,0);
|
WarenkorbArtikel w3= new WarenkorbArtikel(p4,0);
|
||||||
WarenkorbArtikel war;
|
WarenkorbArtikel war= new WarenkorbArtikel();
|
||||||
|
|
||||||
|
|
||||||
}@Test
|
@Test
|
||||||
void TestBerechneGPreis(){
|
void TestBerechneGPreis(){
|
||||||
// assertEquals(1.66,WarenkorbArtikel.berechneGesamtPreis(w1) );
|
|
||||||
|
|
||||||
}
|
assertEquals(1.66, war.berechneGesamtPreis() );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package pack;
|
package pack;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
@ -24,12 +23,8 @@ class WarenkorbTest {
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void Listeerstellen() throws FileNotFoundException { //(4)
|
public void Listeerstellen() { //(4)
|
||||||
/* for (int i = 0; i < 7; i++) {
|
produktListe.add(p1);
|
||||||
String prod = "p" + "i";
|
|
||||||
produktListe.add(prod);
|
|
||||||
|
|
||||||
}*/ produktListe.add(p1);
|
|
||||||
produktListe.add(p2);
|
produktListe.add(p2);
|
||||||
produktListe.add(p3);
|
produktListe.add(p3);
|
||||||
produktListe.add(p4);
|
produktListe.add(p4);
|
||||||
|
|
@ -62,7 +57,7 @@ class WarenkorbTest {
|
||||||
assertEquals(true, warenkorb.ProduktDa(p3.ID,500));
|
assertEquals(true, warenkorb.ProduktDa(p3.ID,500));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void welchesProdukt() throws FileNotFoundException {
|
void welchesProdukt() {
|
||||||
assertEquals(p4, warenkorb.welchesProdukt(27));
|
assertEquals(p4, warenkorb.welchesProdukt(27));
|
||||||
assertEquals(null, warenkorb.welchesProdukt(101));
|
assertEquals(null, warenkorb.welchesProdukt(101));
|
||||||
}
|
}
|
||||||
|
|
@ -71,4 +66,5 @@ class WarenkorbTest {
|
||||||
assertEquals(false, warenkorb.aufLager(p4,300));
|
assertEquals(false, warenkorb.aufLager(p4,300));
|
||||||
assertEquals(true, warenkorb.aufLager(p3,200));
|
assertEquals(true, warenkorb.aufLager(p3,200));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue