public static void main(String[] args) {
    ArrayList<String> nextRoom = new ArrayList<String>();
    nextRoom.add("Room 2");
    Room myRoom =
        new Room(
            "Name",
            "This is a test room",
            nextRoom,
            "Room 3",
            50,
            "Monster 1",
            "This Test Room appears to be empty.");

    System.out.println("Room Name: " + myRoom.getName());

    System.out.println("Room Description: " + myRoom.getDescription());

    for (int i = 0; i < myRoom.getNextRoom().size(); i++) {
      System.out.println("The next room: " + myRoom.getNextRoom().get((i)));
    }

    System.out.println("The previous room: " + myRoom.getPreviousRoom());

    System.out.println("Encounter chance: " + myRoom.getEncounterChance());

    System.out.println("Local monster: " + myRoom.getLocalMonster());

    System.out.println("Empty room Description: " + myRoom.getEmptyRoom());
  }
示例#2
0
  // author Sheila
  public String lookAtRoom() {
    Game game = PemberleyGame.getCurrentGame();
    Room currentRoom = game.getCurrentRoom();
    String roomDescription = currentRoom.getDescription();
    roomDescription = roomDescription + "\nThese are the directions you can move from here: ";
    int i;

    if (currentRoom.getNorth() != null) {
      roomDescription = roomDescription + "NORTH ";
    }
    if (currentRoom.getWest() != null) {
      roomDescription = roomDescription + "WEST ";
    }
    if (currentRoom.getSouth() != null) {
      roomDescription = roomDescription + "SOUTH ";
    }
    if (currentRoom.getEast() != null) {
      roomDescription = roomDescription + "EAST ";
    }

    if (game.getLocalItemNames().length != 0) {
      roomDescription = roomDescription + "\nThese Items are here: ";
      for (String s : game.getLocalItemNames()) {
        roomDescription = roomDescription + s + "-";
      }
    }

    if (game.getLocalActorNames().length != 0) {
      roomDescription = roomDescription + "\nThese People are here: ";
      for (String s : game.getLocalActorNames()) {
        roomDescription = roomDescription + s + "-";
      }
    }

    String[] roomDrawing = currentRoom.getRoomDrawing();

    for (String v : roomDrawing) {
      roomDescription = roomDescription + "\n";
      roomDescription = roomDescription + v;
    }

    return roomDescription;
  }
示例#3
0
文件: Game.java 项目: cjnickel/Clue
 private void setMurderRoom() {
   int index = random.nextInt(13);
   murderRoom = rooms[index];
   System.out.println(murderRoom.getDescription());
 }