From 31b08127903f1a032d768c732bfab2971a6e910f Mon Sep 17 00:00:00 2001 From: Armel Vallet <armel.vallet@etu.univ-amu.fr> Date: Fri, 10 Jan 2025 14:22:25 +0100 Subject: [PATCH] question 8 --- main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index cc70283..7742a21 100644 --- a/main.py +++ b/main.py @@ -38,6 +38,17 @@ class TabletteChocolat: plt.show() plt.close() + def demander_coup(self): + x = input("Couper des lignes (l) ou colonnes (c) ? -> ") + if x == "l": + n = input("Combien de lignes à couper ? Choix possibles : " + str(list(range(1, self.m))) + " -> ") + return t.coupe(int(n), 0) + if x == "c": + n = input("Combien de colonnes à couper ? Choix possibles : " + str(list(range(1, self.n))) + " -> ") + return t.coupe(0, int(n)) + else: + return "Il faut répondre l ou c !" + # Programme principal t = TabletteChocolat(4, 3) @@ -46,4 +57,5 @@ TabletteChocolat(3, 4) print(t.coups_possibles()) print(t.est_possible(0, 1)) print(t.coupe(3, 1)) -t.plot() \ No newline at end of file +t.plot() +print(t.demander_coup()) \ No newline at end of file -- GitLab