Class TreasureChest

java.lang.Object
com.mg105.entities.TreasureChest

public class TreasureChest extends Object
TreasureChest is a class representing the treasure chests in the game. Unopened chests contain an item.
  • Constructor Details

    • TreasureChest

      public TreasureChest(Item reward, Point position)
      Create a new treasure chest at a position with a certain reward. Note that none of these should be null.
      Parameters:
      reward - the reward for opening the chest.
      position - the in-room position of the chest.
  • Method Details

    • getPosition

      public Point getPosition()
      Gets the position of the treasure chest.
      Returns:
      the position of the chest.
    • open

      public Item open()
      If unopened, this will open the chest and return the reward.
      Returns:
      the reward of the chest.
    • isOpened

      public boolean isOpened()
      Gets if this chest has been opened.
      Returns:
      true if this chest has been opened, false otherwise.