Question on removePiece

As I understand it, the method removePiece should not be able to remove a piece in all rotations but only in the “initial form”. Furthermore, the method should not remove “incomplete” forms. Is that correct?

The method should be able to remove a piece in all of its possible rotations. Furthermore, it should only remove complete pieces.

1 Like

Should addPiece be able to add a piece in all its possible rotations, too? Or only in its “initial form”?

It should be able to add it in all of its possible rotations as well. Basically, it should be able to add the piece that it’s given as an argument exactly the way it is.

1 Like

Does it mean, we should check whether the board and the info in the piece matches with each other :? I got confused about what we should check since a broken piece cannot be added to the board.

What is “a broken piece”? All instances that can be constructed using the Factory (and rotating) should be supported, and there is no way to construct other instances…

what I mean by broken piece is that let say we have a L type piece but it stands like I since the last row from the piece is deleted.

I could not understand what should we do in canRemovePiece function.

if the functions work analogously, then we should check whether the every tile in the piece are occupied in the board. But I could not understand why we are doing that check.

Such a piece can not be constructed, so we will not test for it.

So that you know whether the piece can be removed.

Since such a piece cannot be constructed, all the pieces in the board should be properly put in the board.

Then why we are making the check :? All pieces should be able to be removed

Maybe it is so simple but I cannot see, what would be the case where we cannot delete the piece?

Should I assume there might be cases where the rotation point is given wrong or something ?

No, you can not remove a piece if it interjects with the edge, if it is is outside the board, or if it is not there where you wanted to remove it.

For example, if the board has a single I piece standing, you can not remove an O piece from it. If there are two I pieces standing next to each other, you can remove an O piece from it (from the top, middle, or bottom of the two-I-tower).

1 Like

Should it be allowed to remove an O piece out of two I pieces? The description in Board.java for canRemovePiece states

Checks if the piece can be removed, e.g. the coordinates are on the board, and the corresponding positions have the same PieceType as the given piece.

I thought this meant that a piece can only be removed in its entirety and not multiple pieces aligning in a way to coincidentally form another piece.

If this is not the case, what is meant by that explanation?

1 Like

Ah, sorry, I was confused. Indeed, you may only remove a piece if all the “piece parts” (blocks) that would be removed have the type of the piece that is being removed.

2 Likes