Page 239 - thinkpython
P. 239

218                                                         Appendix C. Lumpy

                  Here’s a more complex example using my solution to Exercise 18.6. You can download
                  the code from http://thinkpython.com/code/lumpy_demo8.py  ; you will also need http:
                  //thinkpython.com/code/PokerHand.py  .
                  from swampy.Lumpy import Lumpy

                  from PokerHand import *

                  lumpy = Lumpy()
                  lumpy.make_reference()

                  deck = Deck()
                  hand = PokerHand()
                  deck.move_cards(hand, 7)

                  lumpy.class_diagram()
                  Figure C.8 shows the result. PokerHand inherits from Hand , which inherits from Deck . Both
                  Deck and PokerHand have Cards.

                  This diagram does not show that Hand also has cards, because in the program there are no
                  instances of Hand. This example demonstrates a limitation of Lumpy; it only knows about
                  the attributes and HAS-A relationships of objects that are instantiated.
   234   235   236   237   238   239   240   241