エラー共有後成功
1 parent b3dace9 commit 5ed9d3e34d300f2df655f6c499e6b9071a1d566b
r-nishimura authored on 14 Nov 2023
Showing 3 changed files
View
24
src/ItemsByPrice.java
}
return temp_l1;
}
}
//
//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<Map<String, Object>> getValue() {
// List<Map<String, Object>> temp_l1 = new ArrayList<>();
// {
// for (Map<String, Object> item: this.siteWrapper.getSiteAValue()) {
// if ((Integer) item.get("price") <= this.price.getValue()) {
// temp_l1.add(item);
// }
// }
// }
// return temp_l1;
// }
//}
View
104
src/SSDStore.java
import java.util.List;
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<Map<String, Object>> getSiteA() {
return siteA.getValue();
}
public void addProductToSiteA(int capacity, int price) {
this.siteA.addProductToSiteA(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();
}
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(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 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();
}
}
View
src/SiteWrapper.java