Skip to content
Snippets Groups Projects
Commit fed2ebc3 authored by BiocheH's avatar BiocheH
Browse files

q7 : ajout de plot (et début de demander_coup)

parent 4b40aef2
Branches
No related tags found
No related merge requests found
# rendu de Quentin Hartman
from itertools import chain
import matplotlib.pyplot as plt
class TabletteChocolat:
......@@ -40,6 +41,23 @@ class TabletteChocolat:
'''
return TabletteChocolat(self.m - couple[0], self.n - couple[1])
def plot(self):
plt.gca().set_aspect('equal')
plt.axis('off')
plt.fill([0, self.m, self.m, 0], [0, 0, self.n, self.n], color='#D5B799')
for i in range(self.m):
for j in range(self.n):
plt.plot([i+0.1, i+0.9, i+0.9, i+0.1, i+0.1], [j+0.1, j+0.1, j+0.9, j+0.9, j+0.1], color='#554739')
plt.fill([self.m-0.9, self.m-0.1, self.m-0.1, self.m-0.9], [0.1, 0.1, 0.9, 0.9], color='#554739')
plt.show()
def demander_coup(self):
coup = ''
while not coup in ['l', 'c']:
coup = str(input('Couper des lignes (l) ou des colonnes (c) ? '))
if coup == 'l':
print('voici les coups possibles : ', str(self.coups_possibles()))
A = TabletteChocolat(1, 2)
B = TabletteChocolat(4, 8)
......@@ -51,3 +69,4 @@ print(B.est_possible((3, 0)))
print(B.est_possible((3, 2)))
print(B.coupe((0, 5)))
print(B.coupe((2, 0)))
B.plot()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment