my pick item method with my game class will not work and gives me an error of
add(Item) in Player cannot be applied to (java.lang.String)
can someone help.
here is the pick method within game class
private void pickItem(Command command)
{
if(!command.hasSecondWord()) {
// if there is no second word, we don't know what item you want
System.out.println("what item");
return;
}
String anItem = command.getSecondWord();
// try to pick the item
player.addItem(anItem);
}
and here is the addItem method within player class
public void addItem(Item anItem)
{
if(playerWeight + anItem.getItemWeight() <= MAXWEIGHT){
playerWeight = playerWeight + anItem.getItemWeight();
carriedItems.add(anItem);
}else{
System.out.println("the player isnt Strong enough yet to carry this item");
}
}