Newer
Older
SSDStorePULL / src / SSDStore.java
import java.util.List;
import java.util.Map;

public class SSDStore {
    private Capacity capacity;
    private SiteA siteA; // この参照は不要になる可能性がある
    private SiteB siteB;
    private SiteWrapper siteWrapper;
    private ItemsByCapacity itemsByCapacity;
    private Price price;
    private ItemsByPrice itemsByPrice;

    public SSDStore() {
        this.capacity = new Capacity();
        this.siteA = new SiteA();
        this.siteB = new SiteB();
        //this.siteWrapper = new SiteWrapper();
        this.siteWrapper = new SiteWrapper(siteA, siteB);
        //this.siteWrapper.addSite(this.siteA); // 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);
    }

    // SiteA の直接的な参照は不要になったので、このメソッドは削除するか、変更するかも検討する
    public List<Map<String, Object>> getSiteA() {
        return siteA.getValue();
    }

//    public void addProductToSiteA(int capacity, int price) {
//        List<SiteA> siteAList = this.siteWrapper.getSites();
//        if (!siteAList.isEmpty()) {
//            siteAList.get(0).addProductToSiteA(capacity, price); // 最初の SiteA オブジェクトに製品を追加
//        }
//    }
    public void addProductToSiteA(int capacity, int price) {
        this.siteA.addProductToSiteA(capacity, price);
    }

    public void addProductToSiteB(int capacity, int price) {
        this.siteB.addProductToSiteB(capacity, price);
    }

    public List<Map<String, Object>> getItemsByCapacity() {
        return itemsByCapacity.getValue();
    }

    public int getPrice() {
        return price.getValue();
    }

    public void setPrice(int cur_price) {
        this.price.setPrice(cur_price);
    }

    public List<Map<String, Object>> getItemsByPrice() {
        return itemsByPrice.getValue();
    }
}