parent
68c7766e2c
commit
22e86fcf75
|
|
@ -11,7 +11,7 @@ public class Bestellung {
|
|||
this.storniert = false;
|
||||
};
|
||||
|
||||
public void StorniereBestellung() {
|
||||
public void storniereBestellung() {
|
||||
this.storniert = true;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class OnlineShop {
|
|||
this.bestellungen = new ArrayList<Bestellung>();
|
||||
this.aktuellerWarenkorb = new Warenkorb();
|
||||
};
|
||||
public void AddProdukteVonDatei(ArrayList<String> produktfile) {
|
||||
public void addProdukteVonDatei(ArrayList<String> produktfile) {
|
||||
for(int i = 1; i < produktfile.size(); i++) {
|
||||
String ProduktId = produktfile.get(i).split(",")[0];
|
||||
String ProduktName = produktfile.get(i).split(",")[1];
|
||||
|
|
@ -22,28 +22,28 @@ public class OnlineShop {
|
|||
String ProduktLagerBestand = produktfile.get(i).split(",")[5];
|
||||
|
||||
Produkt temp = new Produkt(Integer.parseInt(ProduktId),ProduktName,(int)Math.round(Double.parseDouble(ProduktGewicht)*1000),(int)Math.round(Double.parseDouble(ProduktPreis)*100),Integer.parseInt(ProduktMwst),Integer.parseInt(ProduktLagerBestand));
|
||||
AddProdukt(temp);
|
||||
addProdukt(temp);
|
||||
}
|
||||
}
|
||||
public void AddProdukt(Produkt neu){
|
||||
public void addProdukt(Produkt neu){
|
||||
this.lager.add(neu);
|
||||
};
|
||||
public ArrayList<String[]> ShowProdukte(){
|
||||
public ArrayList<String[]> showProdukte(){
|
||||
ArrayList<String[]> ret = new ArrayList<String[]>();
|
||||
for(int i = 0; i < this.lager.size(); i++) {
|
||||
ret.add(new String[]{""+this.lager.get(i).id, this.lager.get(i).name, ""+this.lager.get(i).transportGewicht, ""+this.lager.get(i).netto, ""+this.lager.get(i).mwStSatz, ""+this.lager.get(i).lagerbestand});
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public ArrayList<String[]> ShowWarenkorb(){
|
||||
public ArrayList<String[]> showWarenkorb(){
|
||||
ArrayList<String[]> ret = new ArrayList<String[]>();
|
||||
ret.add(new String[] {this.aktuellerWarenkorb.kunde.name,this.aktuellerWarenkorb.kunde.Adresse,""+this.aktuellerWarenkorb.NettoPreis(),""+this.aktuellerWarenkorb.NettoVersandkosten(),""+this.aktuellerWarenkorb.NettoGesamtPreis(),""+this.aktuellerWarenkorb.BruttoPreis(),""+this.aktuellerWarenkorb.BruttoVersandkosten(),""+this.aktuellerWarenkorb.BruttoGesamtPreis(),""+this.aktuellerWarenkorb.Gewicht()});
|
||||
ret.add(new String[] {this.aktuellerWarenkorb.kunde.name,this.aktuellerWarenkorb.kunde.Adresse,""+this.aktuellerWarenkorb.nettoPreis(),""+this.aktuellerWarenkorb.nettoVersandkosten(),""+this.aktuellerWarenkorb.nettoGesamtPreis(),""+this.aktuellerWarenkorb.bruttoPreis(),""+this.aktuellerWarenkorb.bruttoVersandkosten(),""+this.aktuellerWarenkorb.bruttoGesamtPreis(),""+this.aktuellerWarenkorb.gewicht()});
|
||||
for(int i = 0; i < this.aktuellerWarenkorb.inhalt.size(); i++) {
|
||||
ret.add(new String[]{""+this.aktuellerWarenkorb.inhalt.get(i).id, this.aktuellerWarenkorb.inhalt.get(i).name, ""+(this.aktuellerWarenkorb.inhalt.get(i).netto*this.aktuellerWarenkorb.anzahl.get(i)), ""+this.aktuellerWarenkorb.inhalt.get(i).mwStSatz, ""+this.aktuellerWarenkorb.anzahl.get(i)});
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public ArrayList<String[]> SearchProdukt(String substing){
|
||||
public ArrayList<String[]> searchProdukt(String substing){
|
||||
ArrayList<String[]> ret = new ArrayList<String[]>();
|
||||
for(int i = 0; i < this.lager.size(); i++) {
|
||||
if(this.lager.get(i).name.toLowerCase().contains(substing.toLowerCase())) {
|
||||
|
|
@ -52,33 +52,33 @@ public class OnlineShop {
|
|||
}
|
||||
return ret;
|
||||
};
|
||||
public void AddProduktZuWarenkorb(int id, int count){
|
||||
Produkt neu = FindeProduktVonId(id);
|
||||
public void addProduktZuWarenkorb(int id, int count){
|
||||
Produkt neu = findeProduktVonId(id);
|
||||
if(neu == null)
|
||||
return;
|
||||
|
||||
aktuellerWarenkorb.AddProdukt(neu, count);
|
||||
aktuellerWarenkorb.addProdukt(neu, count);
|
||||
};
|
||||
public void DelProduktAusWarenkorb(Produkt del){
|
||||
aktuellerWarenkorb.DelProdukt(del);
|
||||
public void delProduktAusWarenkorb(Produkt del){
|
||||
aktuellerWarenkorb.delProdukt(del);
|
||||
};
|
||||
public void ChangeProduktInWarenkorb(Produkt change, int count){
|
||||
aktuellerWarenkorb.ChangeProdukt(change, count);
|
||||
public void changeProduktInWarenkorb(Produkt change, int count){
|
||||
aktuellerWarenkorb.changeProdukt(change, count);
|
||||
};
|
||||
public void UpdateKundeInWarenkorb(String name, String addr){
|
||||
aktuellerWarenkorb.UpdateKunde(new Kunde(name, addr));
|
||||
public void updateKundeInWarenkorb(String name, String addr){
|
||||
aktuellerWarenkorb.updateKunde(new Kunde(name, addr));
|
||||
};
|
||||
public void AddBestellung(){
|
||||
public void addBestellung(){
|
||||
Warenkorb Bestellkorb = new Warenkorb(this.aktuellerWarenkorb.kunde);
|
||||
for(int i = 0; i<this.aktuellerWarenkorb.inhalt.size(); i++) {
|
||||
Produkt bestelltesProdukt = new Produkt(this.aktuellerWarenkorb.inhalt.get(i).id, this.aktuellerWarenkorb.inhalt.get(i).name, this.aktuellerWarenkorb.inhalt.get(i).transportGewicht, this.aktuellerWarenkorb.inhalt.get(i).netto, this.aktuellerWarenkorb.inhalt.get(i).mwStSatz, this.aktuellerWarenkorb.inhalt.get(i).lagerbestand);
|
||||
Bestellkorb.AddProdukt(bestelltesProdukt, this.aktuellerWarenkorb.anzahl.get(i));
|
||||
Bestellkorb.addProdukt(bestelltesProdukt, this.aktuellerWarenkorb.anzahl.get(i));
|
||||
this.aktuellerWarenkorb.inhalt.get(i).lagerbestand -= this.aktuellerWarenkorb.anzahl.get(i);
|
||||
}
|
||||
bestellungen.add(new Bestellung(bestellungen.size(), Bestellkorb));
|
||||
aktuellerWarenkorb = new Warenkorb();
|
||||
};
|
||||
public ArrayList<String[]> ShowBestellungen(){
|
||||
public ArrayList<String[]> showBestellungen(){
|
||||
ArrayList<String[]> ret = new ArrayList<String[]>();
|
||||
for(int j = 0; j < this.bestellungen.size(); j++) {
|
||||
ret.add(new String[] {""+this.bestellungen.get(j).storniert,this.bestellungen.get(j).bestellungen.kunde.name, this.bestellungen.get(j).bestellungen.kunde.Adresse});
|
||||
|
|
@ -88,15 +88,15 @@ public class OnlineShop {
|
|||
}
|
||||
return ret;
|
||||
};
|
||||
public void StorniereBestellung(Bestellung storniert){
|
||||
public void storniereBestellung(Bestellung storniert){
|
||||
for(int i = 0; i < this.bestellungen.size(); i++) {
|
||||
if(storniert.equals(this.bestellungen.get(i))) {
|
||||
this.bestellungen.get(i).StorniereBestellung();
|
||||
this.bestellungen.get(i).storniereBestellung();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
public void ResetWarenkorb() {
|
||||
public void resetWarenkorb() {
|
||||
this.aktuellerWarenkorb = new Warenkorb();
|
||||
}
|
||||
public Boolean validWarenkorb() {
|
||||
|
|
@ -105,7 +105,7 @@ public class OnlineShop {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public Produkt FindeProduktVonId(int id) {
|
||||
public Produkt findeProduktVonId(int id) {
|
||||
for(int i = 0; i < this.lager.size(); i++) {
|
||||
if(this.lager.get(i).id==id) {
|
||||
return this.lager.get(i);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class OnlineShopTest {
|
|||
ArrayList<String> file = new ArrayList<String>();
|
||||
file.add("rdm");
|
||||
file.add("1,Riesling 0.7 l,1.2,4.2,19,87");
|
||||
o1.AddProdukteVonDatei(file);
|
||||
o1.addProdukteVonDatei(file);
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Produkt p2 = o1.FindeProduktVonId(1);
|
||||
Produkt p2 = o1.findeProduktVonId(1);
|
||||
assertEquals(p1.id,p2.id);
|
||||
assertEquals(p1.name,p2.name);
|
||||
assertEquals(p1.transportGewicht,p2.transportGewicht);
|
||||
|
|
@ -30,7 +30,7 @@ class OnlineShopTest {
|
|||
void testAddProdukt(){
|
||||
OnlineShop o1 = new OnlineShop();
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
o1.AddProdukt(p1);
|
||||
o1.addProdukt(p1);
|
||||
assertTrue(o1.lager.get(0).equals(p1));
|
||||
};
|
||||
|
||||
|
|
@ -38,9 +38,9 @@ class OnlineShopTest {
|
|||
void testShowProdukte(){
|
||||
OnlineShop o1 = new OnlineShop();
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
o1.AddProdukt(p1);
|
||||
o1.addProdukt(p1);
|
||||
ArrayList<String[]> check = new ArrayList<String[]>();
|
||||
check.add(new String[]{"1", "Riesling 0.7 l", "1200", "420", "19", "87"});
|
||||
assertArrayEquals(o1.ShowProdukte().get(0), check.get(0));
|
||||
assertArrayEquals(o1.showProdukte().get(0), check.get(0));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class Produkt {
|
|||
this.lagerbestand = lagerbestand;
|
||||
};
|
||||
|
||||
public void UpdateProdukt(Produkt update) {
|
||||
public void updateProdukt(Produkt update) {
|
||||
this.id = update.id;
|
||||
this.name = update.name;
|
||||
this.transportGewicht = update.transportGewicht;
|
||||
|
|
@ -27,7 +27,7 @@ public class Produkt {
|
|||
this.lagerbestand = update.lagerbestand;
|
||||
};
|
||||
|
||||
public int BruttoPreis() {
|
||||
public int bruttoPreis() {
|
||||
return (int) Math.round(netto*((double)1+((double)mwStSatz)/100));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class ProduktTest {
|
|||
Produkt p2 = new Produkt(1, "test", 100, 100, 10, 20);
|
||||
|
||||
assertFalse(p1.name == p2.name);
|
||||
p2.UpdateProdukt(p1);
|
||||
p2.updateProdukt(p1);
|
||||
assertEquals(p1.id,p2.id);
|
||||
assertEquals(p1.name,p2.name);
|
||||
assertEquals(p1.transportGewicht,p2.transportGewicht);
|
||||
|
|
|
|||
|
|
@ -19,30 +19,30 @@ public class Warenkorb {
|
|||
this.kunde = kunde;
|
||||
};
|
||||
|
||||
public int NettoPreis(){
|
||||
public int nettoPreis(){
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (this.inhalt.get(i).netto*this.anzahl.get(i));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public int BruttoPreis(){
|
||||
public int bruttoPreis(){
|
||||
double tmp = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
tmp += (this.inhalt.get(i).netto*this.anzahl.get(i)*((double)1+((double)this.inhalt.get(i).mwStSatz)/100));
|
||||
}
|
||||
return (int) Math.round(tmp);
|
||||
};
|
||||
public int NettoVersandkosten(){
|
||||
public int nettoVersandkosten(){
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (((this.inhalt.get(i).netto*this.anzahl.get(i))/NettoPreis())*BruttoVersandkosten())/(1+((double)this.inhalt.get(i).mwStSatz/100));
|
||||
ret += (((this.inhalt.get(i).netto*this.anzahl.get(i))/nettoPreis())*bruttoVersandkosten())/(1+((double)this.inhalt.get(i).mwStSatz/100));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
public int BruttoVersandkosten(){
|
||||
public int bruttoVersandkosten(){
|
||||
int ret = 0;
|
||||
int gewicht = Gewicht();
|
||||
int gewicht = gewicht();
|
||||
if(gewicht >= 5000)
|
||||
ret = 1995;
|
||||
if(gewicht < 5000)
|
||||
|
|
@ -55,24 +55,24 @@ public class Warenkorb {
|
|||
ret = 0;
|
||||
return ret;
|
||||
};
|
||||
public int NettoGesamtPreis(){
|
||||
return NettoPreis()+NettoVersandkosten();
|
||||
public int nettoGesamtPreis(){
|
||||
return nettoPreis()+nettoVersandkosten();
|
||||
};
|
||||
public int BruttoGesamtPreis(){
|
||||
return BruttoPreis()+BruttoVersandkosten();
|
||||
public int bruttoGesamtPreis(){
|
||||
return bruttoPreis()+bruttoVersandkosten();
|
||||
};
|
||||
public void AddProdukt(Produkt add, int count){
|
||||
if(IsProduktInWarenkorb(add)) {
|
||||
ChangeProdukt(add, GetProduktAnzahl(add)+count);
|
||||
public void addProdukt(Produkt add, int count){
|
||||
if(isProduktInWarenkorb(add)) {
|
||||
changeProdukt(add, getProduktAnzahl(add)+count);
|
||||
} else {
|
||||
if(count <= add.lagerbestand) {
|
||||
this.inhalt.add(add);
|
||||
this.anzahl.add(count);
|
||||
}
|
||||
}
|
||||
CheckCount(add);
|
||||
checkCount(add);
|
||||
};
|
||||
public void DelProdukt(Produkt del){
|
||||
public void delProdukt(Produkt del){
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(del.equals(this.inhalt.get(i))) {
|
||||
this.inhalt.remove(i);
|
||||
|
|
@ -81,7 +81,7 @@ public class Warenkorb {
|
|||
}
|
||||
}
|
||||
};
|
||||
public void ChangeProdukt(Produkt change, int count){
|
||||
public void changeProdukt(Produkt change, int count){
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(change.equals(this.inhalt.get(i))) {
|
||||
if(count <= this.inhalt.get(i).lagerbestand)
|
||||
|
|
@ -89,29 +89,29 @@ public class Warenkorb {
|
|||
break;
|
||||
}
|
||||
}
|
||||
CheckCount(change);
|
||||
checkCount(change);
|
||||
};
|
||||
public void UpdateKunde(Kunde neu){
|
||||
public void updateKunde(Kunde neu){
|
||||
this.kunde = neu;
|
||||
};
|
||||
private void CheckCount(Produkt check) {
|
||||
private void checkCount(Produkt check) {
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(check.equals(this.inhalt.get(i))) {
|
||||
if(this.anzahl.get(i)<1) {
|
||||
DelProdukt(check);
|
||||
delProdukt(check);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Gewicht() {
|
||||
public int gewicht() {
|
||||
int ret = 0;
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
ret += (this.inhalt.get(i).transportGewicht*this.anzahl.get(i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public Boolean IsProduktInWarenkorb(Produkt zutesten) {
|
||||
public Boolean isProduktInWarenkorb(Produkt zutesten) {
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(zutesten.equals(this.inhalt.get(i))) {
|
||||
return true;
|
||||
|
|
@ -119,7 +119,7 @@ public class Warenkorb {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public int GetProduktAnzahl(Produkt zutesten) {
|
||||
public int getProduktAnzahl(Produkt zutesten) {
|
||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||
if(zutesten.equals(this.inhalt.get(i))) {
|
||||
return this.anzahl.get(i);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class WarenkorbTest {
|
|||
Warenkorb p2 = new Warenkorb(new Kunde("Lukas", "Klipfel"));
|
||||
|
||||
assertFalse(p1.kunde.name == p2.kunde.name || p1.kunde.Adresse == p2.kunde.Adresse);
|
||||
p1.UpdateKunde(new Kunde("Lukas", "Klipfel"));
|
||||
p1.updateKunde(new Kunde("Lukas", "Klipfel"));
|
||||
assertTrue(p1.kunde.name == p2.kunde.name && p1.kunde.Adresse == p2.kunde.Adresse);
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ class WarenkorbTest {
|
|||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertFalse(w1.inhalt.contains(p1));
|
||||
w1.AddProdukt(p1, 2);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.inhalt.contains(p1));
|
||||
};
|
||||
|
||||
|
|
@ -31,9 +31,9 @@ class WarenkorbTest {
|
|||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertFalse(w1.inhalt.contains(p1));
|
||||
w1.AddProdukt(p1, 2);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.inhalt.contains(p1));
|
||||
w1.DelProdukt(p1);
|
||||
w1.delProdukt(p1);
|
||||
assertFalse(w1.inhalt.contains(p1));
|
||||
};
|
||||
|
||||
|
|
@ -41,16 +41,16 @@ class WarenkorbTest {
|
|||
void testChangeProdukt(){
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
w1.AddProdukt(p1, 2);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertFalse(w1.anzahl.get(0)==50);
|
||||
w1.ChangeProdukt(p1, 50);
|
||||
w1.changeProdukt(p1, 50);
|
||||
assertTrue(w1.anzahl.get(0)==50);
|
||||
};
|
||||
|
||||
@Test
|
||||
void testUpdateKunde(){
|
||||
Warenkorb p1 = new Warenkorb();
|
||||
p1.UpdateKunde(new Kunde("Lukas", "Klipfel"));
|
||||
p1.updateKunde(new Kunde("Lukas", "Klipfel"));
|
||||
assertTrue(p1.kunde.name == "Lukas" && p1.kunde.Adresse == "Klipfel");
|
||||
};
|
||||
|
||||
|
|
@ -58,9 +58,9 @@ class WarenkorbTest {
|
|||
void testCheckCount() {
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
w1.AddProdukt(p1, 2);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.inhalt.contains(p1));
|
||||
w1.ChangeProdukt(p1, 0);
|
||||
w1.changeProdukt(p1, 0);
|
||||
assertFalse(w1.inhalt.contains(p1));
|
||||
}
|
||||
|
||||
|
|
@ -68,69 +68,69 @@ class WarenkorbTest {
|
|||
void testGewicht() {
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertTrue(w1.Gewicht()==0);
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.Gewicht()==2400);
|
||||
assertTrue(w1.gewicht()==0);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.gewicht()==2400);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsProduktInWarenkorb() {
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertFalse(w1.IsProduktInWarenkorb(p1));
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.IsProduktInWarenkorb(p1));
|
||||
assertFalse(w1.isProduktInWarenkorb(p1));
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.isProduktInWarenkorb(p1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetProduktAnzahl() {
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.GetProduktAnzahl(p1)==2);
|
||||
w1.ChangeProdukt(p1, 50);
|
||||
assertTrue(w1.GetProduktAnzahl(p1)==50);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.getProduktAnzahl(p1)==2);
|
||||
w1.changeProdukt(p1, 50);
|
||||
assertTrue(w1.getProduktAnzahl(p1)==50);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNettoPreis(){
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertTrue(w1.NettoPreis()==0);
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.NettoPreis()==840);
|
||||
assertTrue(w1.nettoPreis()==0);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.nettoPreis()==840);
|
||||
};
|
||||
|
||||
@Test
|
||||
void testBruttoPreis(){
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",1200,420,19,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertTrue(w1.BruttoPreis()==0);
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.BruttoPreis()==1000);
|
||||
assertTrue(w1.bruttoPreis()==0);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.bruttoPreis()==1000);
|
||||
};
|
||||
|
||||
@Test
|
||||
void testNettoVersandkosten(){
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",10,420,10,87);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertTrue(w1.NettoVersandkosten()==0);
|
||||
w1.AddProdukt(p1, 1);
|
||||
assertTrue(w1.NettoVersandkosten()==359);
|
||||
assertTrue(w1.nettoVersandkosten()==0);
|
||||
w1.addProdukt(p1, 1);
|
||||
assertTrue(w1.nettoVersandkosten()==359);
|
||||
};
|
||||
|
||||
@Test
|
||||
void testBruttoVersandkosten(){
|
||||
Produkt p1 = new Produkt(1,"Riesling 0.7 l",10,420,19,1000);
|
||||
Warenkorb w1 = new Warenkorb();
|
||||
assertTrue(w1.BruttoVersandkosten()==0);
|
||||
w1.AddProdukt(p1, 2);
|
||||
assertTrue(w1.BruttoVersandkosten()==395);
|
||||
w1.ChangeProdukt(p1, 11);
|
||||
assertTrue(w1.BruttoVersandkosten()==495);
|
||||
w1.ChangeProdukt(p1, 110);
|
||||
assertTrue(w1.BruttoVersandkosten()==595);
|
||||
w1.ChangeProdukt(p1, 501);
|
||||
assertTrue(w1.BruttoVersandkosten()==1995);
|
||||
assertTrue(w1.bruttoVersandkosten()==0);
|
||||
w1.addProdukt(p1, 2);
|
||||
assertTrue(w1.bruttoVersandkosten()==395);
|
||||
w1.changeProdukt(p1, 11);
|
||||
assertTrue(w1.bruttoVersandkosten()==495);
|
||||
w1.changeProdukt(p1, 110);
|
||||
assertTrue(w1.bruttoVersandkosten()==595);
|
||||
w1.changeProdukt(p1, 501);
|
||||
assertTrue(w1.bruttoVersandkosten()==1995);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ public class ShopTUI {
|
|||
public static void main(String[] args) throws FileNotFoundException {
|
||||
shop = new OnlineShop();
|
||||
sc = new Scanner(System.in);
|
||||
shop.AddProdukteVonDatei(readFile("resources/produkte.csv"));
|
||||
Menu();
|
||||
shop.addProdukteVonDatei(readFile("resources/produkte.csv"));
|
||||
menu();
|
||||
System.out.println("Ende.");
|
||||
}
|
||||
|
||||
private static void Menu() {
|
||||
private static void menu() {
|
||||
Boolean ende = false;
|
||||
while(!ende) {
|
||||
if(!shop.validWarenkorb()) {
|
||||
UpdateKundeInWarenkorb();
|
||||
updateKundeInWarenkorb();
|
||||
continue;
|
||||
}
|
||||
System.out.println();
|
||||
|
|
@ -43,28 +43,28 @@ public class ShopTUI {
|
|||
int eingabe = Integer.parseInt(""+orgeingabe.charAt(0));
|
||||
switch (eingabe) {
|
||||
case 1 :
|
||||
ShowProdukte();
|
||||
showProdukte();
|
||||
break;
|
||||
case 2 :
|
||||
SearchProdukt();
|
||||
searchProdukt();
|
||||
break;
|
||||
case 3 :
|
||||
AddProdukt();
|
||||
addProdukt();
|
||||
break;
|
||||
case 4 :
|
||||
ShowWarenkorb();
|
||||
showWarenkorb();
|
||||
break;
|
||||
case 5 :
|
||||
ResetWarenkorb();
|
||||
resetWarenkorb();
|
||||
break;
|
||||
case 6 :
|
||||
UpdateKundeInWarenkorb();
|
||||
updateKundeInWarenkorb();
|
||||
break;
|
||||
case 7 :
|
||||
Bestellen();
|
||||
bestellen();
|
||||
break;
|
||||
case 8 :
|
||||
ShowBestellungen();
|
||||
showBestellungen();
|
||||
break;
|
||||
case 9 :
|
||||
ende = true;
|
||||
|
|
@ -75,8 +75,8 @@ public class ShopTUI {
|
|||
}
|
||||
}
|
||||
|
||||
private static void ShowProdukte(){
|
||||
ArrayList<String[]> produkte = shop.ShowProdukte();
|
||||
private static void showProdukte(){
|
||||
ArrayList<String[]> produkte = shop.showProdukte();
|
||||
for(int i = 0; i < produkte.size(); i++) {
|
||||
System.out.println("id: "+produkte.get(i)[0]);
|
||||
System.out.println("Name: "+produkte.get(i)[1]);
|
||||
|
|
@ -87,10 +87,10 @@ public class ShopTUI {
|
|||
System.out.println("");
|
||||
}
|
||||
};
|
||||
private static void SearchProdukt(){
|
||||
private static void searchProdukt(){
|
||||
System.out.println("Bitte schreiben Sie den Suchbegriff:");
|
||||
String orgeingabe = sc.nextLine();
|
||||
ArrayList<String[]> produkte = shop.SearchProdukt(orgeingabe);
|
||||
ArrayList<String[]> produkte = shop.searchProdukt(orgeingabe);
|
||||
for(int i = 0; i < produkte.size(); i++) {
|
||||
System.out.println("id: "+produkte.get(i)[0]);
|
||||
System.out.println("Name: "+produkte.get(i)[1]);
|
||||
|
|
@ -101,7 +101,7 @@ public class ShopTUI {
|
|||
System.out.println("");
|
||||
}
|
||||
};
|
||||
private static void AddProdukt(){
|
||||
private static void addProdukt(){
|
||||
System.out.println("Bitte geben Sie die id des Produktes ein:");
|
||||
String orgeingabe = sc.nextLine();
|
||||
int id = Integer.parseInt(orgeingabe);
|
||||
|
|
@ -120,10 +120,10 @@ public class ShopTUI {
|
|||
return;
|
||||
}
|
||||
}
|
||||
shop.AddProduktZuWarenkorb(id,count);
|
||||
shop.addProduktZuWarenkorb(id,count);
|
||||
};
|
||||
private static void ShowWarenkorb(){
|
||||
ArrayList<String[]> produkte = shop.ShowWarenkorb();
|
||||
private static void showWarenkorb(){
|
||||
ArrayList<String[]> produkte = shop.showWarenkorb();
|
||||
for(int i = 1; i < produkte.size(); i++) {
|
||||
System.out.println("id: "+produkte.get(i)[0]);
|
||||
System.out.println("Name: "+produkte.get(i)[1]);
|
||||
|
|
@ -142,25 +142,25 @@ public class ShopTUI {
|
|||
System.out.println("Brutto Versandkosten: "+produkte.get(0)[6]+"ct");
|
||||
System.out.println("Brutto gesamt: "+produkte.get(0)[7]+"ct");
|
||||
};
|
||||
private static void ResetWarenkorb(){
|
||||
shop.ResetWarenkorb();
|
||||
private static void resetWarenkorb(){
|
||||
shop.resetWarenkorb();
|
||||
};
|
||||
private static void UpdateKundeInWarenkorb(){
|
||||
private static void updateKundeInWarenkorb(){
|
||||
System.out.println("Bitte schreiben Sie ihren Namen:");
|
||||
String name = sc.nextLine();
|
||||
System.out.println("Bitte schreiben Sie ihre Addresse:");
|
||||
String addr = sc.nextLine();
|
||||
shop.UpdateKundeInWarenkorb(name, addr);
|
||||
shop.updateKundeInWarenkorb(name, addr);
|
||||
};
|
||||
private static void Bestellen() {
|
||||
private static void bestellen() {
|
||||
System.out.println("Deine Bestellung mit folgendem Inhalt wurde aufgegeben:");
|
||||
ShowWarenkorb();
|
||||
shop.AddBestellung();
|
||||
showWarenkorb();
|
||||
shop.addBestellung();
|
||||
System.out.println("");
|
||||
System.out.println("");
|
||||
System.out.println("Sie können eine weitere Bestellung aufgeben.");
|
||||
};
|
||||
private static void ShowBestellungen(){ };
|
||||
private static void showBestellungen(){ };
|
||||
|
||||
|
||||
private static ArrayList<String> readFile(String path) throws FileNotFoundException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue