diff --git a/main.py b/main.py index 3bb9e41e1f452aa6c3f2470a25e2da1e58b96590..6c4abbcba03942a51ec7701f2357aa7dc410c605 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ import matplotlib.pyplot as plt -from itertools import chain as ch +import itertools as it class TabletteChocolat: def __init__(self, m, n): self.m=m @@ -7,13 +7,13 @@ class TabletteChocolat: try: self.m==int and self.n==int except : - TypeError, print("Rentrer des entiers") + raise TypeError ("Rentrer des entiers") def __str__(self): return "("+str(self.m) + "x" + str(self.n) + ")" def __repr__(self): - return "Tablette de chocolat de "+ str(self.n) + "x" + str(self.m) + ")" + return "Tablette de chocolat de " + str(self.n) + "x" + str(self.m) + ")" def coups_possibles(self): for i in range(self.m): @@ -22,21 +22,31 @@ class TabletteChocolat: yield (i,j) else: None - #return itertools.chain ?????? -#help(itertools.chain) ?????? + return it.chain #? def est_possible(self, i, j): - for a in list(g): - if a==(i,j): - return "Ce coup est possible" + for a in list(g): #on parcoure la liste des coups possibles + if a==(i,j): #on verifie si le coup en parametre est dans cette derniere + return "Ce coup est possible" #et on repond else: return "Ce coup n est pas possible" #def coupe(self,i,j): + #Une instance est lorsque lon met une vraie valeur a un objet + def plot(self): + plt.axis('equal') + x,y=(i,j) + plt.fill(x,y,"D5B799") #un polygone bleu + plt.fill(x, y, "b",x2, y2, "r") #deux polygone bleu et rouge + plt.show + plt.close + #absolument pas fini en 1h30 cetait un peu juste je pense + #def demander_coup(self): - +help(plt.fill) +#help() t=TabletteChocolat(3,4) print(t) TabletteChocolat(4,3)