1,760
edits
Changes
→Part 2 - Pure Function and Modifiers
'10:20:-1800'
</source>
:7. The result is not correct! So we have to modify and update the change_time() function so that it can handle positive and negative value correctly. The following step is steps are necessary:
::(a) We must first add code to check on the '''second''' attribute of the time object to make sure that it is not less than zero. If it is, we must borrow one from the '''minute''' attribute and add 60 to the '''second''' attribute. We have to repeat this checking until the '''second''' attribute is no long less than zero.
::(b) We then have to add code to check on the '''minute''' attribute. If it is less than zero, we must borrow 1 from the 'hour' attribute and add 60 to the '''minute''' attribute. We have to repeat this checking until the '''minute''' attribute is no long less than zero.