diff --git a/src/ItemsByCapacity.java b/src/ItemsByCapacity.java index faf7f85..7f9ccaf 100644 --- a/src/ItemsByCapacity.java +++ b/src/ItemsByCapacity.java @@ -2,15 +2,15 @@ public class ItemsByCapacity { private Capacity capacity; - private SiteA siteA; - public ItemsByCapacity(Capacity capacity, SiteA siteA) { + private SiteWrapper siteWrapper; + public ItemsByCapacity(Capacity capacity, SiteWrapper siteWrapper) { this.capacity = capacity; - this.siteA = siteA; + this.siteWrapper = siteWrapper; } public List> getValue() { List> temp_l1 = new ArrayList<>(); { - for (Map item: this.siteA.getValue()) { + for (Map item: this.siteWrapper.getSiteAValue()) { if ((Integer) item.get("capacity") >= this.capacity.getValue()) { temp_l1.add(item); } diff --git a/src/ItemsByPrice.java b/src/ItemsByPrice.java index cf04438..fe4b17f 100644 --- a/src/ItemsByPrice.java +++ b/src/ItemsByPrice.java @@ -2,15 +2,15 @@ public class ItemsByPrice { private Price price; - private SiteA siteA; - public ItemsByPrice(Price price, SiteA siteA) { + private SiteWrapper siteWrapper; + public ItemsByPrice(Price price, SiteWrapper siteWrapper) { this.price = price; - this.siteA = siteA; + this.siteWrapper = siteWrapper; } public List> getValue() { List> temp_l1 = new ArrayList<>(); { - for (Map item: this.siteA.getValue()) { + for (Map item: this.siteWrapper.getSiteAValue()) { if ((Integer) item.get("price") <= this.price.getValue()) { temp_l1.add(item); } diff --git a/src/SSDStore.java b/src/SSDStore.java index 692304d..36f3ba0 100644 --- a/src/SSDStore.java +++ b/src/SSDStore.java @@ -1,40 +1,42 @@ import java.util.*; public class SSDStore { + private Price price; private Capacity capacity; private SiteA siteA; + private SiteWrapper siteWrapper; private ItemsByCapacity itemsByCapacity; - private Price price; private ItemsByPrice itemsByPrice; public SSDStore() { + this.price = new Price(); this.capacity = new Capacity(); this.siteA = new SiteA(); - this.itemsByCapacity = new ItemsByCapacity(capacity, siteA); - this.price = new Price(); - this.itemsByPrice = new ItemsByPrice(price, siteA); - } - public int getCapacity() { - return capacity.getValue(); - } - public void setCapacity(int cur_capacity) { - this.capacity.setCapacity(cur_capacity); - } - public List> getSiteA() { - return siteA.getValue(); - } - public void addProductToSiteA(int capacity, int price) { - this.siteA.addProductToSiteA(capacity, price); - } - public List> getItemsByCapacity() { - return itemsByCapacity.getValue(); + this.siteWrapper = new SiteWrapper(siteA); + this.itemsByCapacity = new ItemsByCapacity(capacity, siteWrapper); + this.itemsByPrice = new ItemsByPrice(price, siteWrapper); } public int getPrice() { return price.getValue(); } - public void setPrice(int cur_price) { - this.price.setPrice(cur_price); + public int getCapacity() { + return capacity.getValue(); + } + public List> getSiteA() { + return siteA.getValue(); + } + public List> getItemsByCapacity() { + return itemsByCapacity.getValue(); } public List> getItemsByPrice() { return itemsByPrice.getValue(); } + public void setCapacity(int cur_capacity) { + this.capacity.setCapacity(cur_capacity); + } + public void setPrice(int cur_price) { + this.price.setPrice(cur_price); + } + public void addProductToSiteA(int capacity, int price) { + this.siteA.addProductToSiteA(capacity, price); + } } \ No newline at end of file diff --git a/src/SiteWrapper.java b/src/SiteWrapper.java new file mode 100644 index 0000000..c25318f --- /dev/null +++ b/src/SiteWrapper.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class SiteWrapper { + private SiteA siteA; + public SiteWrapper(SiteA siteA) { + this.siteA = siteA; + } + public List> getSiteAValue() { + return this.siteA.getValue(); + } +} \ No newline at end of file