Skip to content
Snippets Groups Projects
Commit 7126298b authored by KERAOUCHE Sara's avatar KERAOUCHE Sara
Browse files

question 6 et 7

parent 6b4fb8dd
No related branches found
No related tags found
No related merge requests found
import itertools
import matplotlib.pyplot as plt
class tabelettechocolat:
def __init__(self,m,n):
if not isinstance(m, int) or not isinstance(n,int) or m <= 0 or n <= 0:
raise TypeError ("les enties doivent etre entier posistif ")
self.m=m
self.n=n
def __str__(self):
return f"tabelette de chocolat de {self.m}x{self.n}"
def __repr__(self):
return self.__str__()
def coups_possibles(self):
lignes = ((i,0) for i in range (1, self.m))
colonnes = ((0,j) for j in range(1, self.n) )
return itertools.chain(lignes,colonnes)
def est_possible(self,coup):
if not self.est_possible(coup):
raise ValueError
return tabelettechocolat(self.m-i , self.m-j)
def coup(self, coup):
i,j = coup
if not self.est_possible(coup):
raise ValueError
return tabelettechocolat(self.m-i , self.m-j)
def plot(self):
fig,ax = plt.SubplotS
ax.add_patch(plt.Rectangle(0,0))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment