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 |
- If deck is empty then not valid, otherwise valid
|
doMove |
- Move top deck card to pile1
- Move top deck card to pile2
- Move top deck card to pile3
- Move top deck card to pile4
- Number of Cards Left is subtracted by four.
|
ResetDeckMove |
Logic |
valid |
- If deck is empty then valid, otherwise not valid
|
doMove |
- Remove cards one at a time from pile4 and insert to the deck
- Remove cards one at a time from pile3 and insert to the deck
- Remove cards one at a time from pile2 and insert to the deck
- Remove cards one at a time from pile1 and insert to the deck
- Number of Cards Left is set to the size of the deck
|
undo |
FALSE |
MoveCardMove |
Logic |
valid |
- If toPile and draggingCard have the same rank AND toPile is to
the left of fromPile.
|
doMove |
- Insert draggingCard onto toPile
|
RemoveAllMove |
Logic |
valid |
- If the top cards for all four piles in the array have the same
rank
|
doMove |
- Extract these top cards and store into cards Array for undo.
- 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 |
- Store Narcotic Game
|
mousePressed |
-
Find the deck from
model and all four piles
-
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
-
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
-
Refresh Widgets that have been affected
|
NarcoticPileController |
|
constructor |
- Store Narcotic Game and PileView widget
|
mousePressed |
- Get CardView for the top card in the PileView widget associated
with this controller; if no such CardView exists, then ignore action
and return
- Tell Container that this CardView is being dragged and that the
PileView widget is the origination of the source
- Redraw source PileView since it was updated
|
mouseReleased |
-
Get CardView widget being dragged from the container
which we call draggedObject
-
Get card model element for that CardView widget
which we call draggedCard
-
Get source PileView Widget from container that initiated
the drag; from this PileView determine its model element which we
call srcPile.
-
Get PileView associated with controller; from this
PileView determine its model element which we call targetPile
-
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).
-
Refresh the display where the dragged card ended up
and redraw all widgets
-
Be sure to ask container to release the dragging
object, since the move is done.
|
mouseClicked |
- Get all four Pile elements from the Solitaire game
- 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
- 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.