package game.pieces;

import java.awt.Image;
import javax.swing.ImageIcon;

/**
 *
 * @author givanse
 */
public class Square {
    
    private int x; /* position in a board, not pixels */
    private int y; /* position in a board, not pixels */
    private boolean isFalling; // defaults to false
    private SquareType squareType;
    
    public enum SquareType {
        BLUE("img/blue.png"),  
        GREEN("img/green.png"), 
        PINK("img/pink.png"), 
        YELLOW("img/yellow.png"), 
        RED("img/red.png");
        
        /* Add an image property to the elements of this Enum */
        Image image;
        SquareType(String imageFilePath) {
            this.image = new ImageIcon(
                              getClass().getResource(imageFilePath)).getImage();
        }
        public Image getImage() { return this.image; }
    }

    public static int SIZE = 32; // pixels

    Square(SquareType squareType) {
        this(0, 0, squareType);
    }
    
    Square(int x, int y, SquareType squareType) {
        this.x = x;
        this.y = y;
        this.squareType = squareType;
        this.isFalling = true;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        x = x < 0 ? 0 : x;
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        y = y < 0 ? 0 : y;
        this.y = y;
    }

    public SquareType getSquareType() {
        return squareType;
    }

    public boolean isFalling() {
        return this.isFalling;
    }

    public void stopFalling() {
        this.isFalling = false;
    }
    
}

@@ -310,31 +310,35 @@
 e Square
-Type
+Colour
  square
-Type
+Colour
 ;%0A    %0A 
@@ -358,20 +358,22 @@
 m Square
-Type
+Colour
  %7B%0A     
@@ -635,20 +635,22 @@
   Square
-Type
+Colour
 (String 
@@ -916,28 +916,30 @@
 quare(Square
-Type
+Colour
  squareType)
@@ -1015,20 +1015,22 @@
 , Square
-Type
+Colour
  squareT
@@ -1095,20 +1095,22 @@
 s.square
-Type
+Colour
  = squar
@@ -1437,20 +1437,22 @@
 c Square
-Type
+Colour
  getSqua
@@ -1453,20 +1453,22 @@
 etSquare
-Type
+Colour
 () %7B%0A   
@@ -1481,28 +1481,30 @@
 eturn square
-Type
+Colour
 ;%0A    %7D%0A%0A   

refactor SquareType to SquareColour