class Heure:
def __init__(self, heures = 0, minutes = 0):
assert heures >= 0 and minutes >= 0
self.heures = heures
self.minutes = minutes
self.invariant()
def incrementer(self):
self.invariant()
minutesAvant = self.minutes
heuresAvant = self.heures
if (self.minutes < 59):
self.minutes = self.minutes+1
else:
self.minutes = 0
if self.heures < 23:
self.heures = self.heures + 1
else:
self.heures = 0
assert minutesAvant == 59 or self.minutes == minutesAvant+1
assert minutesAvant !=59 or heuresAvant == 23 or (self.heures == heuresAvant+1 and self.minutes == 0)
assert minutesAvant != 59 or heuresAvant != 59 or (self.heures == 0 and self.minutes == 0)
self.invariant()
def __repr__(self):
return repr(self.heures)+":"+repr(self.minutes)
def invariant(self):
assert self.heures >= 0 and self.heures < 24
assert self.minutes >= 0 and self.minutes < 60
heure = Heure()
for i in range(0,1440):
heure.incrementer()
print(heure)