My Game class:
private void goRoom(Command command)
{
if(!command.hasSecondWord())
{
// if there is no second word, we don't know where to go...
System.out.println("Go where?");
return;
}
String direction = command.getSecondWord();
// Try to leave current room.
Room nextRoom = currentRoom.nextRoom(direction);
if (nextRoom == null)
System.out.println("There is no door!");
else
if(nextRoom.isLocked() == true) <-----------------------I want that to call Item class, as isLocked accessor is in there
System.out.println("You need a key to enter this room.");
Item Class:
public class Item
{
// instance variables - replace the example below with your own
private String description;
private int weight;
private boolean isLocked;
/**
* Constructor for objects of class Item
*/
public Item(String description)
{
this.description = description;
weight = 0;
}
public Item(String description, int weight, boolean isLocked)
{
this.description = description;
this.weight = weight;
this.isLocked = isLocked;
}
public boolean isLocked()
{
return isLocked; <------------------This is waht im tryin to get the code on the top to call
}
What is the correct syntax to do this?
Thanks!