Class Room


  • public class Room
    extends java.lang.Object
    Class Room - a room in an adventure game. This class is part of the "World of Zuul" application. "World of Zuul" is a very simple, text based adventure game. A "Room" represents one location in the scenery of the game. It is connected to other rooms via exits. For each existing exit, the room stores a reference to the neighboring room.
    Version:
    2016.02.29
    Author:
    Michael Kölling and David J. Barnes
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.function.IntConsumer Ability  
      (package private) boolean Active_ability  
      (package private) boolean lock  
      (package private) int visable  
    • Constructor Summary

      Constructors 
      Constructor Description
      Room​(java.lang.String description)
      Create a room described "description".
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void AddRoomCharacter​(Character person)
      Add single character to the room
      void AddRoomItems​(Items item)
      Add single item to the room
      void AddRoomItems​(java.util.ArrayList<Items> m_roomItems)
      Puts many items in the room
      void AddVisable​(int change)
      Sets if the room has an active ability
      Character FindCharacters​(java.lang.String person)
      gives character from room if possible
      boolean GetAbility()
      See if the room has an active ability
      Room getExit​(java.lang.String direction)
      Return the room that is reached if we go from this room in direction "direction".
      java.lang.String getExitString()
      Return a string describing the room's exits, for example "Exits: north west".
      boolean getLock()
      Ger lock status
      java.lang.String getLongDescription()
      Return a description of the room in the form: You are in the kitchen.
      java.lang.String getShortDescription()  
      int getVisable()
      Sets if the room has an active ability
      void MinusRoomCharacter​(java.lang.String person)
      takes away single character to the room
      Items MinusRoomItems​(java.lang.String item)
      Takes away item from room
      void Resetroom()
      Resets staus of items and characters in room
      java.lang.String seeRoomCharacters()
      Output items in the room
      java.lang.String seeRoomItems()
      Output items in the room
      void setAbility​(boolean change)
      Sets if the room has an active ability
      void setExit​(java.lang.String direction, Room neighbor)
      Define an exit from this room.
      void setLock​(boolean x)
      set lock status
      void update()
      Update.
      Items useItem​(java.lang.String item)
      gives item from room if possible
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • Ability

        java.util.function.IntConsumer Ability
      • Active_ability

        boolean Active_ability
      • visable

        int visable
      • lock

        boolean lock
    • Constructor Detail

      • Room

        public Room​(java.lang.String description)
        Create a room described "description". Initially, it has no exits. "description" is something like "a kitchen" or "an open court yard".
        Parameters:
        description - The room's description.
    • Method Detail

      • seeRoomItems

        public java.lang.String seeRoomItems()
        Output items in the room
      • seeRoomCharacters

        public java.lang.String seeRoomCharacters()
        Output items in the room
      • useItem

        public Items useItem​(java.lang.String item)
        gives item from room if possible
      • FindCharacters

        public Character FindCharacters​(java.lang.String person)
        gives character from room if possible
      • AddRoomItems

        public void AddRoomItems​(java.util.ArrayList<Items> m_roomItems)
        Puts many items in the room
        Parameters:
        description - The room's description.
      • AddRoomItems

        public void AddRoomItems​(Items item)
        Add single item to the room
      • AddRoomCharacter

        public void AddRoomCharacter​(Character person)
        Add single character to the room
      • MinusRoomItems

        public Items MinusRoomItems​(java.lang.String item)
        Takes away item from room
      • MinusRoomCharacter

        public void MinusRoomCharacter​(java.lang.String person)
        takes away single character to the room
      • Resetroom

        public void Resetroom()
        Resets staus of items and characters in room
      • setExit

        public void setExit​(java.lang.String direction,
                            Room neighbor)
        Define an exit from this room.
        Parameters:
        direction - The direction of the exit.
        neighbor - The room to which the exit leads.
      • getShortDescription

        public java.lang.String getShortDescription()
        Returns:
        The short description of the room (the one that was defined in the constructor).
      • getLongDescription

        public java.lang.String getLongDescription()
        Return a description of the room in the form: You are in the kitchen. Exits: north west
        Returns:
        A long description of this room
      • getExitString

        public java.lang.String getExitString()
        Return a string describing the room's exits, for example "Exits: north west".
        Returns:
        Details of the room's exits.
      • getExit

        public Room getExit​(java.lang.String direction)
        Return the room that is reached if we go from this room in direction "direction". If there is no room in that direction, return null.
        Parameters:
        direction - The exit's direction.
        Returns:
        The room in the given direction.
      • setAbility

        public void setAbility​(boolean change)
        Sets if the room has an active ability
      • GetAbility

        public boolean GetAbility()
        See if the room has an active ability
      • AddVisable

        public void AddVisable​(int change)
        Sets if the room has an active ability
      • getVisable

        public int getVisable()
        Sets if the room has an active ability
      • update

        public void update()
        Update. Incase the item names change we update them after every use command
      • setLock

        public void setLock​(boolean x)
        set lock status
      • getLock

        public boolean getLock()
        Ger lock status