• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Data Encapsulation

If we like the button, we will want to use it for all four answer options. Our instinct is to copy the button for each of four answers (Figure 2.7). This instinct is fine, but immediately we encounter an important problem. Each button is an instance of the same object, and that object is programmed to display the contents of the string variable text. That means that when this movie runs, all four buttons will always sport identical labels (Figure 2.8). The buttons may delight the eye and tickle the mouse finger, but if they offer no actual choice, the players will find this quiz game pretty dull.

Figure 2.7. The Copied Button



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint