Changes

Jump to: navigation, search

Rchan sandbox

7 bytes added, 13:10, 3 November 2019
Investigation II
=Investigation II=
: In the previous investigation, the functions that were defined for manipulating our time object are not tied directly to our time object. Given our time object alone, we won't be able to tell that there exist a function called sum_times() which can be used to add two time objects and return their sum.
:<br>: To tie up those functions to our time objects, we only need to move those functions definition under the class block which define defines our Time object.
== Part 1 - Classes and Methods for our Time objects ==
: The following illustration shows how we can change external functions to become object methods (aka class functions) for our Time object. It is simply by moving the function definitions to be under the class definition for the Time object: <source lang="python">
1,760
edits

Navigation menu