Skip to content
Snippets Groups Projects
Commit 93d0c092 authored by GUYOT Maelis's avatar GUYOT Maelis
Browse files

question4

parent 763dd82f
No related branches found
No related tags found
No related merge requests found
#Imports éventuels #Imports éventuels
import itertools as it
#AJouts de fonctions et méthode #AJouts de fonctions et méthode
class TabletteChocolat: class TabletteChocolat:#création de la classe
def __init__(self,m,n): def __init__(self,m,n):#initialisation du constructeur
self.n=n self.n=n
self.m=m self.m=m
if not isinstance(n,int) or isinstance(m,int): if not isinstance(n,int) or not isinstance(m,int):#permet de sortir une erreur si m et n ne sont pas entiers
raise TypeError raise TypeError
def __str__(self):#surcharge de str
return "Tablette de Chocolat "+str(self.m)+"x"+str(self.n)
def __repr__(self): #surcharge de repr
return "Tablette de chocolat de"+str(self.m)+"x"+str(self.n)
def coups_possibles(self):
g=[]
for i in range(self.m):
for j in range(self.n):
g.append(i,j)
return g
#Programme principal #Programme principal
if __name__='main' #if __name__=='main':
\ No newline at end of file t = TabletteChocolat(3,4)
g = t.coups_possibles()
print(t)
print(g)
\ 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