help with an error

at the moment i'm at home and college lectures are not for another week and im a bit lost

as i have to make this game as a project. its just im gettin an error within the gaem class

which states "addItem(Item) in player cannot be applied to (java.lang.String).

can someone please help and if u need anyother code pleasse just ask...?

within game class

privatevoid 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

Item item = player.addItem(Item);

}

within player class

publicvoid 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");

}

}

[1709 byte] By [mollemana] at [2007-11-26 19:57:13]
# 1
Hi,Item item = player.addItem(Item);Should beItem item = player.addItem(item);Regards,Chris
lordflashearta at 2007-7-9 22:51:47 > top of Java-index,Java Essentials,New To Java...
# 2

> 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

>Item item = player.addItem(Item);

>

>

your item variable has not been created so you cannot use it. I.e

Item item = new Item(); // or whatever other constructor you have

after you 'new' Item, you can then pass it as an argument

hartrafta at 2007-7-9 22:51:47 > top of Java-index,Java Essentials,New To Java...
# 3
Hi,Probably you would want to do:String anItem = command.getSecondWord(); // try to pick the itemItem item = new Item(anItem);player.addItem(item);Regards,Kumar.
kumar_iyera at 2007-7-9 22:51:47 > top of Java-index,Java Essentials,New To Java...
# 4

hi thank you for the help

yet when i try this i get an error of cannot find symbol - constructor Item()

in the line Item item = new Item();

String anItem = command.getSecondWord();

// try to pick the item

Item item = new Item();

player.addItem(item);

mollemana at 2007-7-9 22:51:47 > top of Java-index,Java Essentials,New To Java...
# 5
and sorry...i realised i dont want to create a new item within this method all i want to do is add an item to an array of items within the player class. the item ahas already been created.
mollemana at 2007-7-9 22:51:47 > top of Java-index,Java Essentials,New To Java...
# 6
bump
mollemana at 2007-7-9 22:51:48 > top of Java-index,Java Essentials,New To Java...