Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

need help with my world of zuul game....

807599Feb 28 2007 — edited Feb 28 2007
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");
        }
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2007
Added on Feb 28 2007
17 comments
1,347 views