-2
目前我有增加商品檢索到的循環
public void sellAllBut() {
Iterator<String> i = inventory.iterator();
while (i.hasNext()) {
if (!i.next().equalsIgnoreCase("pickaxe")) {
i.remove();
}
}
}
現在它不僅能消除從inventory.class字符串數組的項目。我如何添加它,以便當它刪除該項目時,它使用inventory.goldCoins + = intvalue添加黃金數量;
我INT值
//ores
int copperoPrice = 150;
int ironoPrice = 200;
int steeloPrice = 350;
int goldoPrice = 500;
int diamondoPrice = 700;
int pickaxePrice = 500;
並獲得放入數組中的項目有:字符串值設置爲礦石
String ore = null;
if (oreFind <= 50) {
ore = "Copper ore";
}
if (oreFind >=51) {
if (oreFind <= 70) {
ore = "Iron ore";
}
}
if (oreFind >=71) {
if (oreFind <= 90) {
ore = "Steel ore";
}
}
if (oreFind >=91) {
if (oreFind <= 99) {
ore = "Gold ore";
}
}
if (oreFind == 100) {
ore = "Diamond ore";
}
後
我使用這行代碼中添加它到我的庫存字符串數組:inventory.addInventory(ore);
因此,例如我的庫存可以有:金剛石礦,金礦,金礦]
我能做些什麼來給個價每這些並把它放在sellAllBut無效?