MikeH
public text v1 · immutable
public class Passageway{
private Room room1;
private Room room2;
/** Constructor: Creates a passageway "connected" to 2 room objects */
public Passageway(Room in, Room out){
room1 = in;
room2 = out;
}
/** Query: Returns the room object connected to the passageway that is
* not the one that is passed to it*/
public Room otherRoom(Room currentRoom){
if (room1.equals(currentRoom)) {
return room2;
}
else
return room1;
}
}