CS361

Project 3
Dragging to legal spots only
due:  Wednesday, February 27, before I leave for the day

Assignment

Add more new features to the Swing window that you created in Project 2:

  1. The user should be allowed to drag aces (and only aces) to the empty slots on the left end of each row.
  2. The user should be allowed to drag a card to any other vacant slot if and only if that card matches the suit of the card immediately to the left of the empty slot and has a value one larger than the card immediately to the left of the slot. For example, in the picture below, the only card that can be dragged into the empty slot in the first row is the ten of hearts.
  3. If the user has managed to drag cards around so that they are lined up ace to king in each row (with an empty space on right end of each row), a message dialog should appear telling the user that they won the game of Carpet Solitaire.
4 rows of 14 slots

Details

  1. When you drag a card to a new slot, the original location of the card should be turned into an empty (gray) slot.
  2. If there are two gray empty slots adjacent to each other, the right gray slot cannot be filled until the left gray slot is filled.
  3. An ace can go in any of the four slots on the left end of the four rows.
  4. Nothing can be dragged to an empty slot if the card immediately to the left of that slot is a king.
  5. If, after releasing the mouse button, the card you were dragging is over a legal empty slot, it should snap into that empty slot.
  6. If, after releasing the mouse button, the card you were dragging is in an illegal place, it should snap back to its starting slot (where it was before you began dragging it).
  7. You can find message dialogs in the Swing JOptionPane class.

Extra Credit

What to hand in

Hand in a hard copy of all the source code files you created or modified and also zip up all source code files and send the zip file to me as an email attachment. See the course web page on handing in assignments for further details.

For fun: An Ambiguous Recommendation

"Brian is only 19, but he has the mental faculties of a man five times his age."