BLACKJACK
Function Invoked / Called by Calls
deal getkey Two calls to dealfromdeck
and one call to
more_to_house
more_to_house deal
dealfromdeck deal and dealstart
builddeck init MCard
MCard builddeck
add_up_player playerdone
playerdone getkey more_to_house, showhouse,
and add_up_player
newgame getkey dealstart
showhouse playerdone
shuffle init swapindeck
swapindeck shuffle
The functions in this example feature a pattern of procedural calls with only init and getkey invoked as a
result of events. Please appreciate the fact that there are many ways to program an application, including
the definition of functions. Generally, it is a good practice to split code up into small functions, but it is not
necessary. There are many places where similar lines of codes are repeated, so there is opportunity to
define more functions. The annotated document follows in Table 10-2.
Table 10-2. The Annotated Code for the Blackjack Game
Code Explanation
<html> Opening tag
<head> Opening tag
<title>Black Jack</title> Complete title element
<style> Opening tag