Newer
Older
import com.example.mampfmobil.ui.Classes.Bestellung;
import com.example.mampfmobil.ui.Classes.BestellungsTeil;
import com.example.mampfmobil.ui.Classes.Customer;
import com.example.mampfmobil.ui.Classes.Deliverer;
import com.example.mampfmobil.ui.Classes.Item;
import com.example.mampfmobil.ui.Classes.ShopItem;
import com.example.mampfmobil.ui.Classes.Supplier;
import java.util.Vector;
public class MampfMobil {
public static Vector<Customer> customers;
public static boolean isInitialized = false;
if(!isInitialized) {
customers = new Vector<>();
deliverers = new Vector<>();
suppliers = new Vector<>();
//create Dummys!!!
customers.add(new Customer("Fabio", "Heyming", "Weinbergstr 70, 55299 Nackenheim"));
customers.add(new Customer("Leah", "Iilyav", "Bad Homburg"));
customers.add(new Customer("Max", "Muster", "Musteradresse"));
deliverers.add(new Deliverer("Mr", "Fahrer", "Fahrstr."));
deliverers.add(new Deliverer("Mrs", "Fahrerin", "Fahrstr."));
suppliers.add(new Supplier("DummyShop", "Dummystreet"));
suppliers.add(new Supplier("Rewe", "Rewestr"));
suppliers.get(0).itemAdd("DummyApfel", 10, 0.5);
suppliers.get(0).itemAdd("DummyBanane", 5, 0.8);
suppliers.get(0).itemAdd("DummyBirne", 10, 0.5);
suppliers.get(0).itemAdd("DummyAnanas", 5, 0.8);
suppliers.get(1).itemAdd("DummyApfel", 10, 0.5);
suppliers.get(2).itemAdd("FreeApfel", 5, 3.4);
Bestellung temp = new Bestellung(suppliers.get(0),true,context.getString(R.string.ordered),customers.get(0));
temp.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 5));
temp.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 2));
temp.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 2));
temp.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 7));
customers.get(0).addBestellung(temp);
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Bestellung temp4 = new Bestellung(suppliers.get(0),true,context.getString(R.string.readyForTransport),customers.get(0));
temp4.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 8));
temp4.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 2));
temp4.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(2).item, 1));
customers.get(0).addBestellung(temp4);
Bestellung temp6 = new Bestellung(suppliers.get(0),true,context.getString(R.string.readyForTransportDelivererFound),customers.get(0));
temp6.deliverer = deliverers.get(0);
temp6.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 8));
temp6.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 2));
temp6.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(2).item, 1));
customers.get(0).addBestellung(temp6);
Bestellung temp5 = new Bestellung(suppliers.get(0),false,context.getString(R.string.readyForPickup),customers.get(0));
temp5.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 8));
temp5.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 2));
temp5.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(2).item, 1));
customers.get(0).addBestellung(temp5);
Bestellung temp2 = new Bestellung(suppliers.get(0),true,context.getString(R.string.inTransportation),customers.get(0));
temp2.deliverer = deliverers.get(0);
temp2.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 5));
temp2.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 10));
temp2.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(2).item, 5));
temp2.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(3).item, 10));
customers.get(0).addBestellung(temp2);
Bestellung temp7 = new Bestellung(suppliers.get(0),true,context.getString(R.string.delivered),customers.get(0));
temp7.deliverer = deliverers.get(0);
temp7.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(0).item, 5));
temp7.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(1).item, 10));
temp7.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(2).item, 5));
temp7.addBestellungsteil(new BestellungsTeil(suppliers.get(0).shopItems.get(3).item, 10));
customers.get(0).addBestellung(temp7);
Bestellung temp3 = new Bestellung(suppliers.get(1),true,"ordered",customers.get(1));
temp3.addBestellungsteil(new BestellungsTeil(suppliers.get(1).shopItems.get(1).item, 7));
temp3.addBestellungsteil(new BestellungsTeil(suppliers.get(1).shopItems.get(0).item, 14));
customers.get(1).addBestellung(temp3);
customers.add(new Customer("", "", ""));
deliverers.add(new Deliverer("", "", ""));
suppliers.add(new Supplier("", ""));
public static boolean findCustomer(String vorname, String nachname){
for(Customer c:customers){
if(c.vorname.equals(vorname) && c.nachname.equals(nachname)){
MampfMobil.currentCustomer = c;
return true;
}
}
return false;
}
public static boolean createCustomer(String vorname, String nachname,String adresse){
for(Customer c:customers){
if(c.vorname.equals(vorname) && c.nachname.equals(nachname)){
return false;
}
}
Customer temp = new Customer(vorname,nachname,adresse);
customers.add(temp);
currentCustomer = temp;
return true;
}
public static boolean findSupplier(String name){
for(Supplier s:suppliers){
if(s.name.equals(name)){
MampfMobil.currentSupplier = s;
return true;
}
}
return false;
}
public static boolean createSupplier(String name,String address){
for(Supplier s:suppliers){
if(s.name.equals(name)){
return false;
}
}
Supplier temp = new Supplier(name,address);
suppliers.add(temp);
currentSupplier = temp;
return true;
}
public static boolean findDeliverer(String vorname, String nachname){
for(Deliverer d:deliverers){
if(d.vorname.equals(vorname) && d.nachname.equals(nachname)){
MampfMobil.currentDeliverer = d;
return true;
}
}
return false;
}
public static boolean createDeliverer(String vorname, String nachname,String address){
for(Deliverer d:deliverers){
if(d.vorname.equals(vorname) && d.nachname.equals(nachname)){
return false;
}
}
Deliverer temp = new Deliverer(vorname,nachname,address);
deliverers.add(temp);
currentDeliverer=temp;
public static int getItemQuantity(Item item){
for(Supplier s:suppliers){
for(ShopItem sI: s.shopItems){
if(sI.item == item){
return sI.quantity;
}
}
}
return 0;
}