Skip to content

Commit 5aa42c0

Browse files
author
Pablo Brasero
committed
Completed: python/clock
1 parent 23bb00c commit 5aa42c0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/clock/clock.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Clock:
2+
def __init__(self, h, m):
3+
self.h = h
4+
self.m = 0
5+
self.add(m)
6+
7+
def __str__(self):
8+
return "%02i:%02i" % (self.h, self.m)
9+
10+
def __eq__(self, other):
11+
return str(self) == str(other)
12+
13+
def add(self, m):
14+
self.m += m
15+
self.h = self.h + self.m / 60
16+
self.m = self.m % 60
17+
self.h = self.h % 24
18+
return self

0 commit comments

Comments
 (0)