Commit 1282f7c9 authored by Matti Henning's avatar Matti Henning
Browse files

Add priceTable to MockImpl to switch between normal and discount Prices.

parent ab39c418
......@@ -14,15 +14,50 @@ class MockDataImpl implements DataAccess {
private final List<Customer> customers;
private final List<Article> articles;
private final List<Order> orders;
private Object[][] priceTable;
MockDataImpl() {
this.articles = new ArrayList<Article>();
this.customers = new ArrayList<Customer>();
this.orders = new ArrayList<Order>();
this.priceTable = new Object[][] {};
}
public void adjustPrice( Article article, Object[][] priceTable ) {
for (int i=0; i<priceTable.length; i++) {
long newPrice = Long.valueOf(priceTable[i][1].toString());
if (article.getId().equals(priceTable[i][0])) {
article.setUnitprice(newPrice);
}
}
}
@Override
public void startup() {
Object[][] priceTable_Normal = new Object[][] {
{ "SKU–458362", 299 }, //Tasse
{ "SKU–693856", 149 }, //Becher
{ "SKU–518957", 2000 }, //Kanne
{ "SKU–638035", 649 }, //Teller
{ "SKU–386035", 2999 }, //Kaffm.
{ "SKU-443803", 1999 }, //Teekoch.
};
Object[][] priceTable_Discount = new Object[][] {
{ "SKU-458362", 249 }, //Tasse
{ "SKU-693856", 99 }, //Becher
{ "SKU-518957", 1499 }, //Kanne
{ "SKU-638035", 499 }, //Teller
{ "SKU-386035", 2499 }, //Kaffm.
{ "SKU-443803", 1499 }, //Teekoch
};
priceTable = priceTable_Normal;
Customer cEric = new Customer( "C86516", "Eric Schulz-Mueller", "eric2346@gmail.com" );
Customer cAnne = new Customer( "C64327", "Meyer, Anne", "+4917223524" );
Customer cNadine = new Customer( "C12396", "Nadine Ulla Blumenfeld", "+4915292454" );
......@@ -39,8 +74,8 @@ class MockDataImpl implements DataAccess {
Article a2 = new Article( "SKU-693856", "Becher", 149, 8400 );
Article a3 = new Article( "SKU-518957", "Kanne", 2000, 2400 );
Article a4 = new Article( "SKU-638035", "Teller", 649, 7000 );
Article a5 = new Article( "SKU-945867", "Kaffeemaschine", 2999, 500 );
Article a6 = new Article( "SKU-592756", "Teekocher", 1999, 2000);
Article a5 = new Article( "SKU-386035", "Kaffeemaschine", 2999, 500 );
Article a6 = new Article( "SKU-443803", "Teekocher", 1999, 2000);
articles.add( a1 );
articles.add( a2 );
......@@ -49,6 +84,10 @@ class MockDataImpl implements DataAccess {
articles.add( a5 );
articles.add( a6 );
for (Article article : articles) {
adjustPrice(article, priceTable);
}
// Eric's 1st order
Order o5234 = new Order( 5234968294L, new Date(), cEric );
OrderItem oi1 = new OrderItem( a3.getDescription(), a3, 1 ); // 1 Kanne (a3)
......@@ -106,6 +145,7 @@ class MockDataImpl implements DataAccess {
public void shutdown() {
// TODO Auto-generated method stub
}
@Override
public List<Customer> getCustomers() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment