public void drop (String name) - if appropriate, remove the item from the ArrayList and add it to the current room. Update the game’s message with one of the following options: 1) the player is not holding that item, 2) the room already has an item, or 3) the player has successfully dropped the item in the room. This is the goal of this method but when I run it it always skipps to the currentMessage in the else statement.
PROBLEM: The problem I am hacing is that when I run this method and try to drop an Item in a room, it doesnt and skips to the else statement and resturns the message "you do not have that item", and I do not know why it is doing this and not working through the first if statement because I am typing an items name I know is in the arraylist.
public void drop(String name)
{
for(Item count : myArray){
if(count.getName().contains(name) && currentRoom.hasItem() == false){
currentRoom.addItem(count);
currentMessage = "you have successfully dropped the item in the room";
myArray.remove(count);
}
else if(count.getName().contains(name) && currentRoom.hasItem() == true)
{
currentMessage = "the room already has an item";
}
else
{
currentMessage = "you do not have that item";
}
}
}