The Essential Guide to HTML5

(Greg DeLong) #1

THE MEMORY (AKA CONCENTRATION) GAME


Function Invoked By/Called By Calls

drawback (^) Invoked as the draw method for a
card in makedeck and flipback
Polycard (^) Called in choose
shuffle (^) Called in init
makedeck (^) Called in init
Card (^) Called by makedeck
drawpoly (^) Called as the draw method of
Polygon in choose
Table 5-2 shows the commented code for the complete polygon version of the application. When reviewing
it, think about the similarities to applications described in other chapters. And remember that this
illustrates just one way to name the applications components and program it. Other ways may work
equally well.
Whatever programming choices you make, put comments in your code (using two slashes per line: //) and
include blank lines. You don't need to comment every line, but doing a decent job of commenting will serve
you well when you have to go back to your code to make improvements.
Table 5- 2. Complete Code for the Polygon Version of the Memory Game


Starting html tag
Starting head tag
Memory game using polygons Complete title
element