Cannot resolve symbol

Reply

Join Date: Apr 2005
Posts: 5
Reputation: drunkpanda is an unknown quantity at this point 
Solved Threads: 0
drunkpanda drunkpanda is offline Offline
Newbie Poster

Cannot resolve symbol

 
0
  #1
Apr 1st, 2005
recently, i bought a textbook call "Objects first with java" for self study. at the chapter 7, design a "Command Line Game" and a exercise ask me to put more functions in the game, as i do so i encounter many problems, and one of the problem as sohowing below, i wonder if anybody can help me

when i add these two codes :

Item textbook = new Item("this is a Java textbook",5);
office.addItem("Textbook",textbook);

the complier tell me:
Cannot resolve symbol constructor Item (java.jang.string,int)


can somebody please tell me what wrong with it thank you very much
---------------------------------------------------------------------------
public class Game 
{
    private Parser parser;
    private Room currentRoom;
    private Player currentPlayer;
   
   
        
    /**
     * Create the game and initialise its internal map.
     */
    public Game() 
    {
        createRooms();
        parser = new Parser();
        
        currentPlayer = new Player("Mark",currentRoom);
    }

    /**
     * Create all the rooms and link their exits together.
     */
    private void createRooms()
    {
        Room outside, theatre, pub, lab, office, cellar;
      
        // create the rooms
        outside = new Room("outside the main entrance of the Polytechnic");
        theatre = new Room("in a lecture theatre");
        pub = new Room("in the campus pub");
        lab = new Room("in a computing lab");
        office = new Room("in the computing admin office");
        cellar = new Room("in the cellar");
        // initialise room exits
        outside.setExit("east", theatre);
        outside.setExit("south", lab);
        outside.setExit("west", pub);

        theatre.setExit("west", outside);

        pub.setExit("east", outside);

        lab.setExit("north", outside);
        lab.setExit("east", office);
        

        office.setExit("west", lab);
        office.setExit("down", cellar);
        cellar.setExit("up", office);
        currentRoom = outside;  // start game outside
        
        // add items 
        Item textbook = new Item("this is a Java textbook",5);
        office.addItem("Textbook",textbook);
    }

some other methods omitted 
Code tags added. -Narue
-------------------------------------------------------------------------
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 192
Reputation: stupidenator is an unknown quantity at this point 
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Re: Cannot resolve symbol

 
0
  #2
Apr 1st, 2005
Where is your Item class?
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 5
Reputation: drunkpanda is an unknown quantity at this point 
Solved Threads: 0
drunkpanda drunkpanda is offline Offline
Newbie Poster

Re: Cannot resolve symbol

 
0
  #3
Apr 1st, 2005
sorry i am just new and i am not sure what might make a good post

item class
-----------------------------------------------
  1. import java.util.HashMap;
  2. import java.util.Set;
  3. import java.util.Iterator;
  4.  
  5.  
  6. public class Item
  7. {
  8. private String description;
  9. private String name;
  10. private int weight;
  11. private boolean moveable;
  12.  
  13.  
  14. /**
  15.   * Constructor for objects of class Item.
  16.   */
  17. public Item(String myDescription, String myName, int myWeight, boolean itemMoveable)
  18. {
  19. this.description = myDescription;
  20. this.name = myName;
  21. this.weight = myWeight;
  22. this.moveable = itemMoveable;
  23. }
  24.  
  25. /**
  26.   * Return the description of the item (the one that was defined
  27.   * in the constructor).
  28.   */
  29. public String getDescription()
  30. {
  31. return description;
  32. }
  33.  
  34. /**
  35.   * Return the name of the item (the one that was defined
  36.   * in the constructor).
  37.   */
  38. public String getName()
  39. {
  40. return name;
  41. }
  42.  
  43. public boolean isMoveable()
  44. {
  45. return (moveable == false);
  46. }
  47.  
  48. /**
  49.   * Return the weight of the item
  50.   */
  51. public int getWeight()
  52. {
  53. return weight;
  54. }
  55.  
  56. }
Code tags added. -Narue
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Cannot resolve symbol

 
0
  #4
Apr 1st, 2005
Well, you don't have a constructor matching the parameter list you're using when you try to create an Item.
That's why you get that error, the compiler cannot find a symbol (meaning a reference to something) with the required signature in the Item class.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 192
Reputation: stupidenator is an unknown quantity at this point 
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Re: Cannot resolve symbol

 
0
  #5
Apr 1st, 2005
in the Item class constructor, you have
public Item(String myDescription, String myName, int myWeight, boolean itemMoveable)
... you're asking for 2 Strings, an int, and a boolean... but then when you construct the Item in the game code, you are only sending it one String, and an int.. they both need to match.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC