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);
}
[I]some other methods omitted [/I]
Code tags added. -Narue
-------------------------------------------------------------------------