limit piece matrix to their minimum size
This commit is contained in:
@ -55,6 +55,8 @@ public class Piece extends Shape{
|
||||
*/
|
||||
public void RotateRight(int times){
|
||||
while(times > 0) {
|
||||
height = matrix.length;
|
||||
width = matrix[0].length;
|
||||
boolean[][] temp_matrix = new boolean[width][height];
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
@ -70,9 +72,10 @@ public class Piece extends Shape{
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Piece){
|
||||
Piece pieceObj = (Piece) obj;
|
||||
if( pieceObj.getPosition().equals(this.getPosition()) && pieceObj.getShape().equals(getShape())) {
|
||||
return true;
|
||||
if (pieceObj.getPosition() != null && this.getPosition() != null){
|
||||
return pieceObj.getPosition().equals(this.getPosition()) && pieceObj.getShape().equals(getShape());
|
||||
}
|
||||
return pieceObj.getShape().equals(getShape());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user