Page 1 of 1

r20503

PostPosted: 21 Mar 2013, 16:29
by myk
Hey Max, I reverted 20503 and added a comment explaining why it was written the way it was. The throw was there specifically to warn against misalignment between showCard() and flipCard().

Re: r20503

PostPosted: 21 Mar 2013, 19:57
by Max mtg
I see the comment about misalignment... but don't understand how that misaligment can ever happen.
Especially, if we add
Code: Select all
this.flipped = false;
at line 62.

Re: r20503

PostPosted: 21 Mar 2013, 22:35
by myk
the way the code is currently written, the two functions are in alignment. every case that is handled in showCard() is handled in flipCard(). The exception will never be thrown in current code. The throw is there to make it obvious that something is wrong if showCard() is modified in the future to handle additional types, but flipCard() is forgotten. I'll clarify the comment in the code.

I'll add flipped = false at line 62 for clarity, but it is not strictly necessary. currentCard being null is enough to ensure the logic in flipCard is never run (see the first line of flipCard()).