From e2e074dc22fd1fd6007560788237a131a296c711 Mon Sep 17 00:00:00 2001
From: Armel Vallet <armel.vallet@etu.univ-amu.fr>
Date: Fri, 10 Jan 2025 14:33:41 +0100
Subject: [PATCH] question 9

---
 main.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/main.py b/main.py
index 7742a21..89e039d 100644
--- a/main.py
+++ b/main.py
@@ -39,12 +39,15 @@ class TabletteChocolat:
         plt.close()
 
     def demander_coup(self):
+        n = 0
         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)
+            while not self.est_possible(int(n), 0):
+                n = input("Combien de lignes à couper ? Choix possibles : " + str(list(range(1, self.m))) + " -> ")
+            return self.coupe(int(n), 0)
         if x == "c":
-            n = input("Combien de colonnes à couper ? Choix possibles : " + str(list(range(1, self.n))) + " -> ")
+            while not self.est_possible(0, int(n)):
+                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 !"
-- 
GitLab