
takeitem4
By:
ace on
Aug 18th, 2010 | syntax:
None | size: 0.94 KB | hits: 16 | expires: Never
public String takeItem(String itemName)
{
Item item = currentRoom.itemCheck(itemName);
if(currentRoom.roomContents() == false)
{
return "there is nothing here.";
}
if(currentRoom.roomContents() == true)
{
if(item.getItemWeight() > strength)
{
return "" + itemName + " is too heavy";
}
if(item.getItemWeight() <= strength - encumberance)
{
items.add(item);
encumberance = encumberance + item.getItemWeight();
return "you have taken " + itemName;
}
else
{
return "You are carrying too much to take " + item.getItemName();
}
}
return null;
}