I'm trying to instantiate a String object that I read from a file and then set the value of that object as an object of a custom class (Room). Any advice on how I can do that?
This is what I have so far:
String roomName = scanner.hasNext() ? scanner.next() : "";
//scanning the name of the room from file
if(room == "room"){
Room roomName = new Room(roomName);
}
So basically, I'm trying to set the roomName string that I read from the file, and then set that same value as the name of the Room object.
EDIT: the file that I'm trying to read will have either a "door" value or a "room" value, which is why I check if the value is a "room" or not.
The Room class is instantiated like so:
Room room0 = new Room(0);
The sample file I read is something like this:
room 0 wall wall wall
door d0 0 1 close