forked from psounis/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomparison.py
More file actions
25 lines (22 loc) · 742 Bytes
/
Copy pathcomparison.py
File metadata and controls
25 lines (22 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Time:
def __init__(self, hour, minute, second):
self.hour = hour
self.minute = minute
self.second = second
def __str__(self):
return f"{str(self.hour).zfill(2)}:" \
f"{str(self.minute).zfill(2)}:" \
f"{str(self.second).zfill(2)}"
def __gt__(self, other):
if self.hour > other.hour:
return True
elif self.hour == other.hour:
if self.minute > other.minute:
return True
elif self.minute == other.minute:
if self.second > other.second:
return True
return False
t = Time(11,2,3)
t2 = Time(11,11,1)
print(f"{t} > {t2}: {t>t2}")