Format for A1.Design [READY]

Please conform to the following format when completing your A1.design. Note that the full example I give for Narcotic is brief because the rules of Narcotic are brief.

You are asked to provide the following deliverables.

Full Class Diagrams

For your controller and move classes, you must produce full diagrams, including constructors and attributes. Make sure you identify full signatures for all methods

Move Pseudo-code

For each move class you are to show the logic for doMove and valid. No need to describe 'undo' since it is assumed to be the opposite of doMove (unless if you choose NOT to do an undo, then simply place FALSE there).

DealFourMove Logic
valid
  1. If deck is empty then not valid, otherwise valid
doMove
  1. Move top deck card to pile1
  2. Move top deck card to pile2
  3. Move top deck card to pile3
  4. Move top deck card to pile4
  5. Number of Cards Left is subtracted by four.

 

ResetDeckMove Logic
valid
  1. If deck is empty then valid, otherwise not valid
doMove
  1. Remove cards one at a time from pile4 and insert to the deck
  2. Remove cards one at a time from pile3 and insert to the deck
  3. Remove cards one at a time from pile2 and insert to the deck
  4. Remove cards one at a time from pile1 and insert to the deck
  5. Number of Cards Left is set to the size of the deck
undo FALSE

 

MoveCardMove Logic
valid
  1. If toPile and draggingCard have the same rank AND toPile is to the left of fromPile.
doMove
  1. Insert draggingCard onto toPile

 

RemoveAllMove Logic
valid
  1. If the top cards for all four piles in the array have the same rank
doMove
  1. Extract these top cards and store into cards Array for undo.
  2. Update score by +4

Controller Mapping

For each view widget that exists in your solitaire game, describe the controller that will be used to manage the mouse events that occur over it; these include mouse pressed, released, clicked, entered, exited, moved, and dragged.

Note that I expect you will focus on pressed, released, and clicked (because the others are either irrelevant or already handled for you by the solitaire infrastructure).

I show by the Narcotic example the format that is expected:

View Widget Controller Type
DeckView NarcoticDeckController
PileView NarcoticPileController

Controller Pseudo-code

Now for each controller, you will need to sketch out in "pseudo-code" what is to happen. First explain the constructor for your controller (since it may need to be configured properly) Then describe what the controller should do. To properly understand the actions of your controller, you will need to know the specialized behavior of the View widgets that you are using (i.e., how can you extract cards from them). Look, for example, at the description below of NarcoticPileController and its mousePressed behavior

NarcoticDeckController  

constructor

  1. Store Narcotic Game

mousePressed

  1. Find the deck from model and all four piles

  2. If deck is empty, construct a DealFourMove object from the deck and its four piles. Try to make move. If it is a valid move then have solitaire game store move

  3. If deck is not empty, construct a ResetDeckMove object from the deck and its four piles. Try to make move. If it is a valid move then have solitaire game store move

  4. Refresh Widgets that have been affected

 

NarcoticPileController  

constructor

  1. Store Narcotic Game and PileView widget

mousePressed

  1. Get CardView for the top card in the PileView widget associated with this controller; if no such CardView exists, then ignore action and return
  2. Tell Container that this CardView is being dragged and that the PileView widget is the origination of the source
  3. Redraw source PileView since it was updated

mouseReleased

  1. Get CardView widget being dragged from the container which we call draggedObject

  2. Get card model element for that CardView widget which we call draggedCard

  3. Get source PileView Widget from container that initiated the drag; from this PileView determine its model element which we call srcPile.

  4. Get PileView associated with controller; from this PileView determine its model element which we call targetPile

  5. construct a MoveCardMove object from the srcPile, targetPile, and draggedCard; try to make move. If this move is a valid move then store with the solitaire game; otherwise, return the draggedObject to the PileView from whence it came (using the returnWidget method).

  6. Refresh the display where the dragged card ended up and redraw all widgets

  7. Be sure to ask container to release the dragging object, since the move is done.

mouseClicked

  1. Get all four Pile elements from the Solitaire game
  2. Construct a RemoveAllMove object from the four pile elements; try to make move. If this move is a valid move then store with the solitaire game
  3. Redraw all widgets that may have been affected.

End-Notes

The full Narcotic implementation is now available on the Eclipse project area for your perusal. Execute the class "NarcoticFinal" and review the StarUML diagram found in package tutorial.vfinal in that project.