Advertisement
WONGDEEM

Untitled

May 8th, 2019
124
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Duration:
  2.     def __init__(self, minutes, seconds):
  3.         self.minutes = minutes
  4.         self.seconds = seconds
  5.         self.total_seconds = self.minutes*60 + self.seconds
  6.        
  7.     def get_minutes(self):
  8.         return self.total_seconds // 60
  9.        
  10.     def get_seconds(self):
  11.         return self.total_seconds % 60
  12.        
  13.     def __str__(self):
  14.         if self.get_seconds() < 10:
  15.             a = "0" + str(self.get_seconds())
  16.         else:
  17.             a = str(self.get_seconds())
  18.         if self.get_minutes() < 10:
  19.             b = "0" + str(self.get_minutes())
  20.         else:
  21.             b = str(self.get_minutes())
  22.         return b + ":" + a
  23.    
  24.     def __add__(self, new_duration):
  25.         return Duration(self.minutes + new_duration.minutes, self.seconds + new_duration.seconds)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement