Chris Posted August 12, 2015 Posted August 12, 2015 (edited) I want it to withdraw food from this array public static String[] food = { "Shrimp","Trout","Salmon","Tuna","Lobster","Swordfish","Monkfish","Shark" }; im calling it this way and (may not be the best way but is an example) if (s.bank.isOpen()){ //do banking if (!s.inventory.contains(food)){ if (s.getBank().contains(food)){ s.bank.withdrawAll(food); } } } and i get this error i tried fixing it with intelj but this does not work Edited August 12, 2015 by Sinatra
Botre Posted August 12, 2015 Posted August 12, 2015 I want it to withdraw food from this array public static String[] food = { "Shrimp","Trout","Salmon","Tuna","Lobster","Swordfish","Monkfish","Shark" }; im calling it this way if (s.bank.isOpen()){ //do banking if (!s.inventory.contains(food)){ if (s.getBank().contains(food)){ s.bank.withdrawAll(food); } } } and i get this error i tried fixing it with intelj but this does not work You are passing an array to a method that only takes a String parameter. Possible solution: for(String f; food) { if(!getBank().contains(f)) continue; else { getBank().withdrawAll(f); break; } }
Chris Posted August 12, 2015 Author Posted August 12, 2015 You are passing an array to a method that only takes a String parameter. Possible solution: for(String f; food) { if(!getBank().contains(f)) continue; else { getBank().withdrawAll(f); break; } } hmm okay ill work with this and thanks for the fast response 1
Joseph Posted August 12, 2015 Posted August 12, 2015 Slow stepping. Find item using item container. Item item = Bank.getItem (food); Bank.withdrawAll(item.getName ()); Just do a null check on the item. hmm okay ill work with this and thanks for the fast response You are passing an array to a method that only takes a String parameter. Possible solution: for(String f; food) { if(!getBank().contains(f)) continue; else { getBank().withdrawAll(f); break; } }
Chris Posted August 12, 2015 Author Posted August 12, 2015 Slow stepping. Find item using item container. Item item = Bank.getItem (food); Bank.withdrawAll(item.getName ()); Just do a null check on the item. you are who they say you are java guru 1