diff --git a/src/ItemsByPrice.java b/src/ItemsByPrice.java index f39dac7..451d33d 100644 --- a/src/ItemsByPrice.java +++ b/src/ItemsByPrice.java @@ -20,4 +20,28 @@ } return temp_l1; } -} \ No newline at end of file +} +// +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Map; +// +//public class ItemsByPrice { +// private Price price; +// private SiteWrapper siteWrapper; +// public ItemsByPrice(Price price, SiteWrapper siteWrapper) { +// this.price = price; +// this.siteWrapper = siteWrapper; +// } +// public List> getValue() { +// List> temp_l1 = new ArrayList<>(); +// { +// for (Map item: this.siteWrapper.getSiteAValue()) { +// if ((Integer) item.get("price") <= this.price.getValue()) { +// temp_l1.add(item); +// } +// } +// } +// return temp_l1; +// } +//} \ No newline at end of file diff --git a/src/SSDStore.java b/src/SSDStore.java index 9eb4f8e..e1409d6 100644 --- a/src/SSDStore.java +++ b/src/SSDStore.java @@ -2,43 +2,56 @@ import java.util.Map; public class SSDStore { - private Capacity capacity; - private SiteA siteA; - private SiteWrapper siteWrapper; - private ItemsByCapacity itemsByCapacity; - private Price price; - private ItemsByPrice itemsByPrice; - public SSDStore() { - this.capacity = new Capacity(); - this.siteA = new SiteA(); - this.siteWrapper = new SiteWrapper(); - this.siteWrapper.addSite(new SiteA()); - this.itemsByCapacity = new ItemsByCapacity(capacity, siteWrapper); - this.price = new Price(); - this.itemsByPrice = new ItemsByPrice(price, siteWrapper); - } - 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(); - } - public int getPrice() { - return price.getValue(); - } - public void setPrice(int cur_price) { - this.price.setPrice(cur_price); - } - public List> getItemsByPrice() { - return itemsByPrice.getValue(); - } + private Capacity capacity; + private SiteA siteA; // ���̎Q�Ƃ͕s�v�ɂȂ�”\�������� + private SiteWrapper siteWrapper; + private ItemsByCapacity itemsByCapacity; + private Price price; + private ItemsByPrice itemsByPrice; + + public SSDStore() { + this.capacity = new Capacity(); + this.siteA = new SiteA(); + this.siteWrapper = new SiteWrapper(); + this.siteWrapper.addSite(this.siteA); // SiteA �I�u�W�F�N�g��lj� + this.itemsByCapacity = new ItemsByCapacity(capacity, siteWrapper); + this.price = new Price(); + this.itemsByPrice = new ItemsByPrice(price, siteWrapper); + } + + public int getCapacity() { + return capacity.getValue(); + } + + public void setCapacity(int cur_capacity) { + this.capacity.setCapacity(cur_capacity); + } + + // SiteA �̒��ړI�ȎQ�Ƃ͕s�v�ɂȂ����̂ŁA���̃��\�b�h�͍폜���邩�A�ύX���邩���������� + public List> getSiteA() { + return siteA.getValue(); + } + + public void addProductToSiteA(int capacity, int price) { + List siteAList = this.siteWrapper.getSites(); + if (!siteAList.isEmpty()) { + siteAList.get(0).addProductToSiteA(capacity, price); // �ŏ��� SiteA �I�u�W�F�N�g�ɐ��i��lj� + } + } + + public List> getItemsByCapacity() { + return itemsByCapacity.getValue(); + } + + public int getPrice() { + return price.getValue(); + } + + public void setPrice(int cur_price) { + this.price.setPrice(cur_price); + } + + public List> getItemsByPrice() { + return itemsByPrice.getValue(); + } } \ No newline at end of file diff --git a/src/SiteWrapper.java b/src/SiteWrapper.java index 2b6cbda..027d0e8 100644 --- a/src/SiteWrapper.java +++ b/src/SiteWrapper.java @@ -4,11 +4,16 @@ public class SiteWrapper { private List sites = new ArrayList<>(); - + public void addSite(SiteA site) { sites.add(site); } + // ���݂� SiteA �I�u�W�F�N�g�̃��X�g��Ԃ����\�b�h + public List getSites() { + return this.sites; + } + public List> getSiteValue() { List> combinedList = new ArrayList<>(); for (SiteA site : sites) { @@ -16,4 +21,5 @@ } return combinedList; } + } \ No newline at end of file