BLACKJACK
Function Invoked / Called by Callsdeal getkey Two calls to dealfromdeck
and one call to
more_to_housemore_to_house dealdealfromdeck deal and dealstartbuilddeck init MCardMCard builddeckadd_up_player playerdoneplayerdone getkey more_to_house, showhouse,
and add_up_playernewgame getkey dealstartshowhouse playerdoneshuffle init swapindeckswapindeck shuffleThe 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