xxxx Cannot be resolved to a type

I am writing a Text based adventure game and I feel like I have a good layout but, I do not seem to understand why I am getting this error. I feel like it's because I do not have a Room.java class but, if I did I am not sure what I would put in it because the code that I am following everything for the rooms such as description, exiting and input is all in the one class so my question is. How can I resolve this problem and if I have to create a Room class what do I put in it?

Here is my code
package com.game.white;

interface GameState{
	void setCurrentRoom(Room room);
}

public class Locations implements GameState{
	private final Room startingRoom;
	private Room currentRoom;
	
	public void Location(){
	this.startingRoom = new Room("You fall slowly from the illuminating sky into a dark and\n",
				 "gloomy marsh. You look up to see a crack of light coming out of the\n",
				 "clouds. You have no memory of ever being up there or on this world.\n",
				 "You look around and see trees surrounding you in all directions.\n",
				 "To the (east) is a large tree that may be worth investigating and to\n",
				 "the (north) are trees venturing in may be dangerous. Off into the (west)\n",
				 "you hear movement. To the (south) are large amounts of trees.");
	
	//Add all other rooms here...
	
	//create a room changer for each room
	
	}
	//add a way to read current room. hint. use the interface { }
	
	/*Create the play (way to read input, where you start, while loop for if 
	 * input == null then display current room and what the text reads if input ! 
	 * recognized
	 */
}

I suppose I could add
class Room { void setCurrentRoom(Room room); }

Yeah that idea ^ there didn't work at all. Gave me a lot more problems lol.

EDIT: I tried to make a room class and add a method for Room to hold variable String but, I came up with the same error. Sadly.

Comments

  • If you dont have a Room class how do you expect to be able to do [icode]private Room currentRoom;[/icode]

    What do you expect this to do other than create an instance of a Room class?
  • If you dont have a Room class how do you expect to be able to do [icode]private Room currentRoom;[/icode]

    What do you expect this to do other than create an instance of a Room class?

    That's what I am saying lol but, I can't think for the life of me what I would put in the Room class
    
    public class Room{
    
    //So I need to make a type Room with String, String
    
    }
    

    If I am wrong please help guide me but, I can't think of how to do this very well, sadly.
  • I have no idea. Its your game, you determine the design. Maybe Room should be an object that owns and describes all items within that room as well as links to connected rooms. Or maybe the Room class shouldnt even exist. You cant code what you dont understand. Once you figure out what the Room class should do for you, if anything, you'll know what to put there.
Sign In or Register to comment.