Page 233 -
P. 233

custom data objects



                        Test Drive




                       With these changes applied to your program, let’s ensure you continue to get the same results as
                       earlier. Load your code into IDLE and run it.














                                                             The code to the “sanitize()” function is
                                                              not shown here, but it is still part of this
                                                              program.






















                                                                                        Cool! There’s no
                                                                                        change here.





                                   And to make objects
                                   do more, I just add more
                                   methods, right?



                                      Yes, that’s correct: more functionality = more methods.
                                      Simply add methods to encapsulate the new functionality you need within
                                      your class. There’s no limit to how many methods a class can have, so feel
                                      free to knock yourself out!
                                                                                      you are here 4    197
   228   229   230   231   232   233   234   235   236   237   238