finish class OnlineShop
parent
6352556d36
commit
a45c6d8fad
|
|
@ -14,30 +14,78 @@ public class OnlineShop {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void AddProdukt(Produkt neu){
|
public void AddProdukt(Produkt neu){
|
||||||
|
this.lager.add(neu);
|
||||||
};
|
};
|
||||||
public void UpdateExistingProdukt(Produkt alt, Produkt neu){
|
public void UpdateExistingProdukt(Produkt alt, Produkt neu){
|
||||||
|
for(int i = 0; i < this.lager.size(); i++) {
|
||||||
|
if(alt.equals(this.lager.get(i))) {
|
||||||
|
this.lager.set(i, neu);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
public String[] ShowWarenkorb(){
|
public ArrayList<String[]> ShowProdukte(){
|
||||||
return new String[0];
|
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 String[] SearchProdukt(){
|
public ArrayList<String[]> ShowWarenkorb(){
|
||||||
return new String[0];
|
ArrayList<String[]> ret = new ArrayList<String[]>();
|
||||||
|
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).transportGewicht, ""+this.aktuellerWarenkorb.inhalt.get(i).netto, ""+this.aktuellerWarenkorb.inhalt.get(i).mwStSatz, ""+this.aktuellerWarenkorb.inhalt.get(i).lagerbestand, ""+this.aktuellerWarenkorb.anzahl.get(i)});
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
public void AddProduktZuWarenkorb(Produkt add){
|
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.contains(substing)) {
|
||||||
|
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 void AddProduktZuWarenkorb(Produkt add, int count){
|
||||||
|
if(count <= add.lagerbestand)
|
||||||
|
aktuellerWarenkorb.AddProdukt(add, count);
|
||||||
};
|
};
|
||||||
public void DelProduktAusWarenkorb(Produkt del){
|
public void DelProduktAusWarenkorb(Produkt del){
|
||||||
|
aktuellerWarenkorb.DelProdukt(del);
|
||||||
};
|
};
|
||||||
public void ChangeProduktInWarenkorb(Produkt change, int count){
|
public void ChangeProduktInWarenkorb(Produkt change, int count){
|
||||||
|
aktuellerWarenkorb.ChangeProdukt(change, count);
|
||||||
};
|
};
|
||||||
public void UpdateKundeInWarenkorb(Kunde neu){
|
public void UpdateKundeInWarenkorb(Kunde neu){
|
||||||
|
aktuellerWarenkorb.UpdateKunde(neu);
|
||||||
};
|
};
|
||||||
public void AddBestellung(Warenkorb bestellung){
|
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));
|
||||||
|
this.aktuellerWarenkorb.inhalt.get(i).lagerbestand -= this.aktuellerWarenkorb.anzahl.get(i);
|
||||||
|
}
|
||||||
|
bestellungen.add(new Bestellung(bestellungen.size(), Bestellkorb));
|
||||||
|
aktuellerWarenkorb = new Warenkorb();
|
||||||
};
|
};
|
||||||
public String[] ShowBestellungen(){
|
public ArrayList<String[]> ShowBestellungen(){
|
||||||
return new String[0];
|
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});
|
||||||
|
for(int i = 0; i < this.bestellungen.get(j).bestellungen.inhalt.size(); i++) {
|
||||||
|
ret.add(new String[]{""+this.bestellungen.get(j).bestellungen.inhalt.get(i).id, this.bestellungen.get(j).bestellungen.inhalt.get(i).name, ""+this.bestellungen.get(j).bestellungen.inhalt.get(i).transportGewicht, ""+this.bestellungen.get(j).bestellungen.inhalt.get(i).netto, ""+this.bestellungen.get(j).bestellungen.inhalt.get(i).mwStSatz, ""+this.bestellungen.get(j).bestellungen.inhalt.get(i).lagerbestand, ""+this.bestellungen.get(j).bestellungen.anzahl.get(i)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,18 @@ public class Warenkorb {
|
||||||
public ArrayList<Integer> anzahl;
|
public ArrayList<Integer> anzahl;
|
||||||
public Kunde kunde;
|
public Kunde kunde;
|
||||||
|
|
||||||
public Warenkorb(Kunde kunde) {
|
|
||||||
this.inhalt = new ArrayList<Produkt>();
|
|
||||||
this.anzahl = new ArrayList<Integer>();
|
|
||||||
this.kunde = kunde;
|
|
||||||
};
|
|
||||||
|
|
||||||
public Warenkorb() {
|
public Warenkorb() {
|
||||||
this.inhalt = new ArrayList<Produkt>();
|
this.inhalt = new ArrayList<Produkt>();
|
||||||
this.anzahl = new ArrayList<Integer>();
|
this.anzahl = new ArrayList<Integer>();
|
||||||
this.kunde = new Kunde("","");
|
this.kunde = new Kunde("","");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public Warenkorb(Kunde kunde) {
|
||||||
|
this.inhalt = new ArrayList<Produkt>();
|
||||||
|
this.anzahl = new ArrayList<Integer>();
|
||||||
|
this.kunde = kunde;
|
||||||
|
};
|
||||||
|
|
||||||
public int NettoPreis(){
|
public int NettoPreis(){
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||||
|
|
@ -60,9 +60,11 @@ public class Warenkorb {
|
||||||
return BruttoPreis()+BruttoVersandkosten();
|
return BruttoPreis()+BruttoVersandkosten();
|
||||||
};
|
};
|
||||||
public void AddProdukt(Produkt add, int count){
|
public void AddProdukt(Produkt add, int count){
|
||||||
this.inhalt.add(add);
|
if(count <= add.lagerbestand) {
|
||||||
this.anzahl.add(count);
|
this.inhalt.add(add);
|
||||||
CheckCount(add);
|
this.anzahl.add(count);
|
||||||
|
CheckCount(add);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
public void DelProdukt(Produkt del){
|
public void DelProdukt(Produkt del){
|
||||||
for(int i = 0; i < this.inhalt.size(); i++) {
|
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||||
|
|
@ -76,7 +78,8 @@ 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++) {
|
for(int i = 0; i < this.inhalt.size(); i++) {
|
||||||
if(change.equals(this.inhalt.get(i))) {
|
if(change.equals(this.inhalt.get(i))) {
|
||||||
this.anzahl.set(i, count);
|
if(count <= this.inhalt.get(i).lagerbestand)
|
||||||
|
this.anzahl.set(i, count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue