Class Block

java.lang.Object
jadex.bdi.blocksworld.Block
Direct Known Subclasses:
Table

public class Block extends Object
A block in the blocks-world.
  • Field Details

    • number

      protected int number
      The number of the block.
    • color

      protected Color color
      The color of the block.
    • lower

      protected Block lower
      The block where this block is located on.
    • upper

      protected Block upper
      The block located on upper of this block.
    • pcs

      The helper object for bean events.
    • dx

      protected double dx
      The x translation for drawing (0-1).
    • dy

      protected double dy
      The y translation for drawing (0-1).
  • Constructor Details

    • Block

      public Block(Color color, Block lower)
      Create a new block.
      Parameters:
      color - The color of the block.
      lower - The block where this block is located on.
    • Block

      public Block(int number, Color color, Block lower)
      Create a new block.
      Parameters:
      number - The number of the block.
      color - The color of the block.
      lower - The block where this block is located on.
  • Method Details

    • getNumber

      protected static int getNumber()
      Get an instance number.
    • getColor

      public Color getColor()
      Get the color of the block.
      Returns:
      The color of the block.
    • getLower

      public Block getLower()
      Get the block where this block is located on.
      Returns:
      The block where this block is located on.
    • getUpper

      public Block getUpper()
      Get the upper.
      Returns:
      The upper.
    • isClear

      public boolean isClear()
      Check if this block is clear.
    • stackOn

      public void stackOn(Block lower)
      Move this block on top of another block.
    • setLower

      protected void setLower(Block lower)
      Set the lower block, where this block is located on.
      Parameters:
      lower - The lower block.
    • addBlock

      protected void addBlock(Block block)
      Add a block to this block.
    • removeBlock

      protected void removeBlock(Block block)
      Remove a block from this block.
    • toString

      public String toString()
      Create a string representation of this block.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Check for equality.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a PropertyChangeListener to the listener list. The listener is registered for all properties.
      Parameters:
      listener - The PropertyChangeListener to be added.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
      Parameters:
      listener - The PropertyChangeListener to be removed.