Building Memory… Day 4 – November 20, 2006

advertisement
Building Memory…
Day 4 – November 20, 2006
Some clean up from last
time
• Applet class can now be run as either
an Applet or an Application
• Made picture from card appear
(needed to set its Dimension)
• Also needed to set the Dimension of
the DrawingCanvas
We want to flip!
• Changed card to take in a
DrawingCanvas as a parameter to the
constructor and the card puts itself
on the canvas
Card
• Has a state
• It is either face up or face down
• Starts face down
Card States
• Are composed of the image that they
should display when a card is in that
state.
• Creating an instance of a card state
causes the correct picture to be
displayed.
Flip!
• Need to add a mouse listener to the
images to get them to respond
correctly to the user’s desire for the
cards to flip.
What should a card do
when flipped?
• The old image should be removed
from the canvas
• The card should change state
• The new image should be placed on
the canvas
Open issues
• There are lots, but one that came up
during class:
– Taking care of multiple cards on the
screen
• We need to be able to independently place
each card
• Perhaps that info needs to be a parameter
Download