zuul2
This commit is contained in:
@@ -16,13 +16,13 @@ package de.szut.zuul;
|
||||
*/
|
||||
public class Room
|
||||
{
|
||||
public String description;
|
||||
public Room northExit;
|
||||
public Room southExit;
|
||||
public Room eastExit;
|
||||
public Room westExit;
|
||||
public Room upExit;
|
||||
public Room downExit;
|
||||
private String description;
|
||||
private Room northExit;
|
||||
private Room southExit;
|
||||
private Room eastExit;
|
||||
private Room westExit;
|
||||
private Room upExit;
|
||||
private Room downExit;
|
||||
|
||||
/**
|
||||
* Create a room described "description". Initially, it has
|
||||
@@ -74,5 +74,39 @@ public class Room
|
||||
{
|
||||
return description;
|
||||
}
|
||||
public String exitsToString() {
|
||||
StringBuilder exitsInString = new StringBuilder();
|
||||
|
||||
if (northExit != null) {
|
||||
exitsInString.append("north ");
|
||||
}
|
||||
if (eastExit != null) {
|
||||
exitsInString.append("east ");
|
||||
}
|
||||
if (southExit != null) {
|
||||
exitsInString.append("south ");
|
||||
}
|
||||
if (westExit != null) {
|
||||
exitsInString.append("west ");
|
||||
}
|
||||
if (upExit != null) {
|
||||
exitsInString.append("up ");
|
||||
}
|
||||
if (downExit != null) {
|
||||
exitsInString.append("down ");
|
||||
}
|
||||
|
||||
return exitsInString.toString().trim();
|
||||
}
|
||||
public Room getExits(String direction) {
|
||||
return switch (direction) {
|
||||
case "north" -> northExit;
|
||||
case "east" -> eastExit;
|
||||
case "south" -> southExit;
|
||||
case "west" -> westExit;
|
||||
case "up" -> upExit;
|
||||
case "down" -> downExit;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user