2bad2rage 0 Share Posted October 22, 2016 This is my code for selling items to the shop that are not currently in the shop but it seems to me that the getShop().contains(i) does not work? If someone could clear this up for me that would be great. List<Item> inv = getInventory().getCollection(); for (Item i : inv) { if (getShop().contains(i) == true) { continue; } else { if ((getShop().fullSlotCount() < 39)) { getShop().sell(i, 1); } } } Link to comment Share on other sites More sharing options...
Mad 86 Share Posted October 22, 2016 because you can't compare objects using ==, have to use .equals Link to comment Share on other sites More sharing options...
Pandemic 2675 Share Posted October 22, 2016 Item's equal method checks for amount, so the contains method wouldn't work there, try using contains(i.getID()) instead. Link to comment Share on other sites More sharing options...
Mad 86 Share Posted October 22, 2016 Oh i don't even know why i wrote that lol, didn't even make sense... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.