Created
August 23, 2020 19:00
-
-
Save immmdreza/0488a3f5e327dc78cefd3a6c1a831956 to your computer and use it in GitHub Desktop.
noooo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Clock: | |
_Second : int = 0 | |
_Minutes : int = 0 | |
_Hours : int = 0 | |
def FillMe(self, totalSeconds: int): | |
if(totalSeconds >= 60): | |
if(totalSeconds >= 3600): | |
self._Hours = totalSeconds//3600 | |
hoursRemaning = totalSeconds%3600 | |
if(hoursRemaning >= 60): | |
self._Minutes = hoursRemaning//60 | |
self._Second = hoursRemaning%60 | |
else: | |
self._Minutes = 0 | |
self._Second = hoursRemaning | |
else: | |
self._Hours = 0 | |
self._Minutes = totalSeconds//60 | |
self._Second = totalSeconds%60 | |
else: | |
self._Second = totalSeconds | |
self._Hours = 0 | |
self._Minutes = 0 | |
def FillMeByProps(self, hours: int, mins: int, secs: int): | |
self._Hours = hours | |
self._Minutes = mins | |
self._Second = secs | |
def __str__(self): | |
return f'{self._Hours} Hours, {self._Minutes} Mins, {self._Second} Seconds'; | |
def GetTotalSecounds(self) -> int: | |
return (self._Hours*3600) + (self._Minutes*60) + self._Second | |
def GetTotalMinutes(self): | |
return self.GetTotalSecounds()/60 | |
def GetTotalHours(self): | |
return self.GetTotalSecounds()/3600 | |
c = Clock() | |
c.FillMe(200000) | |
print(c); | |
print(c.GetTotalSecounds()) | |
print(c.GetTotalMinutes()) | |
print(c.GetTotalHours()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment