Skip to content
Snippets Groups Projects
Commit 63a68bc6 authored by Leo Litaize's avatar Leo Litaize
Browse files

Question 7..

parent c963b29e
No related branches found
No related tags found
No related merge requests found
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from itertools import chain as ch import itertools as it
class TabletteChocolat: class TabletteChocolat:
def __init__(self, m, n): def __init__(self, m, n):
self.m=m self.m=m
...@@ -7,7 +7,7 @@ class TabletteChocolat: ...@@ -7,7 +7,7 @@ class TabletteChocolat:
try: try:
self.m==int and self.n==int self.m==int and self.n==int
except : except :
TypeError, print("Rentrer des entiers") raise TypeError ("Rentrer des entiers")
def __str__(self): def __str__(self):
return "("+str(self.m) + "x" + str(self.n) + ")" return "("+str(self.m) + "x" + str(self.n) + ")"
...@@ -22,21 +22,31 @@ class TabletteChocolat: ...@@ -22,21 +22,31 @@ class TabletteChocolat:
yield (i,j) yield (i,j)
else: else:
None None
#return itertools.chain ?????? return it.chain #?
#help(itertools.chain) ??????
def est_possible(self, i, j): def est_possible(self, i, j):
for a in list(g): for a in list(g): #on parcoure la liste des coups possibles
if a==(i,j): if a==(i,j): #on verifie si le coup en parametre est dans cette derniere
return "Ce coup est possible" return "Ce coup est possible" #et on repond
else: else:
return "Ce coup n est pas possible" return "Ce coup n est pas possible"
#def coupe(self,i,j): #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) t=TabletteChocolat(3,4)
print(t) print(t)
TabletteChocolat(4,3) TabletteChocolat(4,3)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment