Boolean equals in piece

I’m confused when i read the project presentation. it said that piece has one particularities which is boolean equals. Which is not in the interface. Should i make this by my self? And what does “If PieceType, rotation, rotation point match” mean?

Hi there!

We’ve had a similar question here, which should answer the first part of your question, so you can go and check that out.

As for the second part of your question, this is actually fairly straightforward. Since the equals method from the Object class, which your Piece class inherits by default, only returns true if the two pieces are exactly the same piece (and by that I mean that they are literally the same piece, so they aren’t just perfect clones, they are one and the same), you need to overwrite that method so it actually implements our idea of equality. That idea being that two pieces are to be considered equal if and only if they are of the same PieceType (so an L piece is never equal to an I piece), and have the same rotation point and the same orientation, which is to ensure that our pieces are only considered the same if they have been rotated an equal \mod 4 number of times (because pieces of different orientations don’t necessarily look like each other, and even if they do, and their rotation points don’t match they might behave differently when rotated, as they might end up occupying different coordinates).